G
G
gremlintv22018-03-14 15:30:54
Nginx
gremlintv2, 2018-03-14 15:30:54

How to write nginx location with regular expression on alias?

Those that are:

location ~ ^/video/.+\.m3u8|ts$ {
root /var/www/html/;

The ones that should be:
location ~ /video/^.+\.m3u8|ts$ {
alias /var/www/my_video/$1;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2018-03-14
@megafax

If you just look for files in this folder.

location ~ /video/^.+\.(m3u8|ts)$ {
  alias /var/www/my_video/;
  try_files $uri =404;
}

If it is also divided into folders inside my_video, and the folder name is like the file name
location ~^ /video/^(.+)\.(m3u8|ts)$ {
  alias /var/www/my_video/$1/;
  try_files $uri =404;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question