url rewrite, nginx выдает 404 ошибки, ничего в журналах ошибок

ниже rewrite работает нормально:

rewrite ^/city/restaurants$ /city/listings/restaurants permanent;

но это не работает

rewrite ^/city/restaurants$ /city/listings/restaurants last;
rewrite ^/city/restaurants$ /city/listings/restaurants break;

что я делаю не так?

ниже всего серверного блока 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 ~* \.php$ {
                            include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                            #fastcgi_pass unix:/var/run/php5-fpm.sock;
                            fastcgi_pass 127.0.0.1:9000;
                            #try_files $uri @rewrite;
                            }
                    try_files $uri @rewrite;
                    }

            location @rewrite {
                    rewrite ^ /index.php;
            }
            location ~* \.(?:ico|css|js|gif|jpg|jpeg|png)$
            {
                    try_files $uri $uri/;
                    expires 30d;

             }
}
1
задан 13 January 2016 в 15:58
1 ответ

Сначала переместите перезапись ключа из блока местоположения во включающий блок server . Это упростит вашу логику.

Затем разрешите перезапись журнала отладки , чтобы убедиться, что полученное вами сообщение 404 исходит от исходного URL-адреса или переписанного URL-адреса.

Наконец, если основная причина все еще не найдена , включите общий журнал отладки для Nginx:

error_log /path/to/log debug;
0
ответ дан 4 December 2019 в 06:41

Теги

Похожие вопросы