I just found that my nginx syntax was not correct:
location /news { rewrite ^(.*)$ /blog redirect;}
I want to redirect mysite.com/news to mysite.com/blog but that code was redirecting more pages to blog.
Anyone can help me explaining the error and tell me how to correctly redirect?
thanks
The best practice would be to still use a
location. If you don't want anything below/newsto redirect to/blog(e.g., no need for a wildcard), then the following is what you want, and is probably the most efficient way to create a single alias:Otherwise, if you do, in fact, want a wildcard:
P.S. Also note that
redirectwould cause302redirects; if you want301, then the keyword is calledpermanent.