下面的重写工作正常:
rewrite ^/city/restaurants$ /city/listings/restaurants permanent;
Run Code Online (Sandbox Code Playgroud)
但这不起作用
rewrite ^/city/restaurants$ /city/listings/restaurants last;
rewrite ^/city/restaurants$ /city/listings/restaurants break;
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
位于整个 nginx 服务器块下方
server {
listen 80 default backlog=1024;
server_name mydomain.com;
client_max_body_size 20M;
charset utf-8;
keepalive_timeout 50;
access_log /var/log/access_log main;
error_log /var/log/error_log info;
root /var/www/;
index index.php index.phtml index.html;
autoindex on;
location ~ \..*/*\.php$ {
return 403;
}
location ~^/sites/.*/private/{
return 403;
}
location ~^/sites/.*/files/* {
try_files $uri @rewrite;
}
location ~ (^|/)\. {
return 403;
}
location / {
rewrite ^/city/restaurants$ /city/listings/restaurants last;
location …
Run Code Online (Sandbox Code Playgroud)