Use try_files to redirect /dir1 to /dir2 in nginx -
i have part of websites still using old urls.
essentially, want:
http://hostname/app1/static/dir1
--> http://hostname/app1/static/dir2
.
the static
directory may contain other resources being used.
i tried following getting cycle caused nginx abort:
location ^~ /app1/static/ { alias /home/app1_user/app1/static/; try_files /app1/static/dir1 /app1/static/dir2; }
what should instead?
if understand correctly, -
a file, e.g. /app1/static/file.jpg
try_files
in /home/app1_user/app1/dir1/file.jpg
, /home/app1_user/app1/dir2/file.jpg
, lastly 404 if can't found.
location ~ ^/app1/static/(.*)$ { alias /home/app1_user/app1/static/; try_files dir1/$1 dir2/$1 =404; }
Comments
Post a Comment