I have a virtual host like below for my Yii website
server { root /var/www/code; index index.php index.html; server_name example.com; location / { rewrite ^/en/keyword$ /en/spesfic_controller/ last; .... } }
if i use last or break in the above rewrite rule, nginx throws 404 error, but if i change it to permanent, it will redirect it and will work fine!! what might be wrong? or what i missed?
(nothing in error log)
EDIT
the full virtual host is below:
server { listen 80; root /var/www/code; index index.php index.html; server_name example.com; location / { rewrite ^/[/]*$ /ar/ permanent; proxy_set_header Accept-Encoding ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?q=$1 last; } } rewrite ^/en/jobs-in-riyadh$ "/en/jobs/SearchResult/city_id/a:1:%7Bi:0;s:2:%2210%22;%7D" last; error_log /var/log/nginx/error.log warn; access_log /var/log/nginx/access.log; if ($http_user_agent ~ libwww-perl) { return 403; } location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|ttf|woff)$ { access_log off; log_not_found off; expires max; #you can set it to something like 30d; add_header Pragma public; add_header Cache-Control "public"; #you can set more than one COMMA seperated ", must-revalidate, proxy-revalidate"; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/code/$fastcgi_script_name; fastcgi_buffer_size 4k; fastcgi_buffers 256 4k; fastcgi_max_temp_file_size 0; proxy_buffering off; send_timeout 180s; proxy_read_timeout 120s; proxy_connect_timeout 120s; fastcgi_send_timeout 120s; fastcgi_read_timeout 120s; fastcgi_connect_timeout 120s; } location ~ /\. { access_log off; log_not_found off; deny all; } }