rewrite to www EXCEPT for one directory

Ian Evans ianevans at digitalhit.com
Thu Sep 6 18:22:07 UTC 2012


I have the following in my nginx.conf to redirect to www. to deal with 
Google duplicate issues.

server {
server_name example.com
listen 80;
location / {
rewrite ^(.*) http://www.example.com$1 permanent;
}
}

However, WordPress, which I'm installing in /blogs, is strongly 
suggesting that we drop the www, at least for WordPress.

Is there a way to change the above config so it will do the "add www" 
redirect EXCEPT for when the location is /blogs or below? (it's a 
multisite install so there'll be /blogs/blog1, /blogs/blog2, etc)



More information about the nginx mailing list