I've got problems with simple SEO friendly redirect. Web page has changed and I'd like to redirect old uris to new ones. For example I'd like to redirect /contact to /contact.html
I've tried
location = /contact {
rewrite ^ /contact.html permanent;
}
But it seems's that it doesn't work and Nginx keeps passing request to Zend front controller (PHP).
Here's my current configuration (without rewrites)
server {
listen *:80;
server_name www.domain1.com domain1.com domain2.com www.domain2.com;
error_log /var/log/nginx/domain1.error.log notice;
root /home/domain1/www/public/;
client_max_body_size 22M;
#domain redirect
if ($host != 'www.domain1.com' ) {
rewrite ^/(.*)$ http://www.domain1.com/$1 permanent;
}
location / {
index index.php;
}
# html cache static content
location ~* \.(js|css|rdf|xml|ico|txt|gif|jpg|png|jpeg|swf|eot|ttf|woff)$ {
expires 30d;
}
rewrite /path1/(\w*)/\w*\.(\w*) /path2/$1.$2;
#Zend front controller
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
break;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9200;
fastcgi_param SCRIPT_FILENAME /home/domain1/www/public$fastcgi_script_name;
fastcgi_param APPLICATION_ENV production;
include /etc/nginx/fastcgi_params;
}
}