How to redirect single url in nginx?

By | May 31, 2015

We need to redirect something like:

http://example.com/issue1 --> http://example.com/shop/issues/custom_isse_name1
http://example.com/issue2 --> http://example.com/shop/issues/custom_isse_name2
http://example.com/issue3 --> http://example.com/shop/issues/custom_isse_name3

this can be achieved in two ways:

location /issue {
   rewrite ^/issue(.*) http://$server_name/shop/issues/custom_issue_name$1 permanent;
 }

or
location /issue1 {
   rewrite ^/.* http://$server_name/shop/issues/custom_issue_name1 permanent;
}
location /issue2 {
   rewrite ^.* http://$server_name/shop/issues/custom_issue_name2 permanent;
}
Сomments аrchive