rewrite - How to prevent nginx rewriting again after adding index file? -
i'm trying write nginx rewrite rules web server, , 1 of them simple as:
index index.html; ... rewrite ^/(.*)$ /web/$1 break;
this rule adds /web
before uri. works query www.mydomain.com/somefile
, returns content of /docroot/web/somefile
.
however, if query www.mydomain.com/somedir/
, rule applied twice: @ first uri rewritten /web/somedir/
. nginx changes /web/somedir/index.html
according index index.html
. after this, rewrite rule applied again , gets uri of /web/web/somedir/index.html
.
how solve problem?
i don't think need rewrite rule that, try adding root in server.
if website uses sort of url rewrites need add those, if need please explain how want urls rewritten , i'll you.
server { server_name example.com; root /docroot/web; #make sure put web index index.html; location / { try_files $uri $uri/ =404; } }
Comments
Post a Comment