Answer the question
In order to leave comments, you need to log in
What is wrong with rewrite Nginx?
In general, I do this:
location / {
root "%hostdir%";
index index.php index.html index.htm;
rewrite ^([^.]*[^/])$ $1/ permanent;
rewrite ^/admin/$ index.php?type=admin;
}
location = /admin/ {
rewrite ^(.*)$ /index.php?type=admin;
}
location = /admin/ {
rewrite ^(.*)$ /index.php?type=admin;
rewrite ^people$ /index.php?type=admin&module=people;
}
Answer the question
In order to leave comments, you need to log in
It's all about slash.
Instead ,
you need it rewrite ^/admin/$ /index.php?type=admin;
,
and it will work. In your example, which is in location, there is just a slash.
As for the second rewrite (people), the slash at the end is missing. You need to do this:
In this case www.site.ru/admin/people/
, it will work, BUT then it will not work without a slash. You can remove the $ , then it will work for any URLs that start with www.site.ru/admin/people
, i.e. and for www.site.ru/admin/people/
and for www.site.ru/admin/people-f////
.
If you need for the version with and without a slash, then you can do this:
rewrite ^people/?$ /index.php?type=admin&module=people;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question