Nginx 301 redirect syntax error -


i found nginx syntax not correct:

location /news { rewrite ^(.*)$ /blog redirect;} 

i want redirect mysite.com/news mysite.com/blog code redirecting more pages blog.

anyone can me explaining error , tell me how correctly redirect?

thanks

the best practice still use location. if don't want below /news redirect /blog (e.g., no need wildcard), following want, , efficient way create single alias:

location = /news {     return 301 /blog; } 

otherwise, if do, in fact, want wildcard:

location /news {     rewrite ^/news(.*)  /blog$1 permanent; } 

p.s. note redirect cause 302 redirects; if want 301, keyword called permanent.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -