小编Ola*_*ger的帖子

url重写,nginx抛出404错误,错误日志中没有任何内容

下面的重写工作正常:

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)

mod-rewrite rewrite nginx regex http-status-code-404

5
推荐指数
1
解决办法
1万
查看次数