Subdirectory still redirecting to www. despite rule

Ian M. Evans ianevans at
Wed Sep 19 00:25:53 UTC 2012

This issue is connected to the threads

rewrite to www EXCEPT for one directory
( and

Nginx location rule for Wordpress Multisite in subdirectories

After making the changes to my nginx.conf. I reloaded the config. After
going to the browser still
redirected to

Here are the applicable lines in the conf:

server {
listen 80;

location / {
 return 301$request_uri;

location ^~ /blogs {
  try_files $uri /blogs/index.php?q=$uri;
  location ~ \.php$ {
if ($uri ~ (/blogs/[^/]*)) {
  set $blogname $1;
location ^~ /blogs/$blogname {
  try_files $uri $blogname/index.php?q=$uri;
  location ~ \.php$ {

I'm wondering if it's an error in combining the config advice for the two
separate issues in the two threads.


More information about the nginx mailing list