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

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -