Reroute NGINX path to another path (without http redirect) -


i want able go these urls below

http://assets.mydomain.com/static/style.css

http://assets.mydomain.com/v999/static/style.css

and in nginx, either urls above should instead point

/var/www/vhosts/mysite/public/static/style.css

how can this? had thought case of doing alias doesn't seem case

ie.

location ~* ^/v(.*)/ {     alias $rootpath; } 

but doesn't seem work. below full nginx config.

server {     set $rootpath /var/www/vhosts/mysite/public;      listen 80;      server_name assets.mydomain.com;      root $rootpath;      access_log /var/log/nginx/access_assets.log;     error_log /var/log/nginx/error_assets.log debug;      index index.html index.htm;      # files matching these extensions cached long time     location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {         expires max;         add_header cache-control public;     }      # don't throw errors missing favicons , don't display them in logs     location /favicon.ico {         log_not_found off;         access_log off;         error_log off;     }      # deny these extensions     location ~* \.(txt|php|less)$ {         deny all;     }      # deny attempts access hidden files such .htaccess, .htpasswd, .ds_store (mac).     # keep logging requests parse later (or pass firewall utilities such fail2ban)     location ~ /\. {         deny all;     }      location ~* ^/v(.*)/ {         alias $rootpath;     }      location / {         try_files $uri $uri/;     } } 

what need only:

server {     set $rootpath /var/www/vhosts/mysite/public;      listen 80;      server_name assets.mydomain.com;      root $rootpath;      location /v999/ {         root $rootpath;     }     ...  }  

see location on nginx docs


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -