Www redirect

Hi, I am using rtcamp’s easyengine script. I used it to install wordpress with w3tc, restore a wordpress site that I had on another host, and everything is working beautifully. However, it only works if I go to the root domain. If it’s www. or http://www. it doesn’t work. I see you have a guide here: (http://rtcamp.com/tutorials/nginx/www-non-www-redirection/) on how to redirect. But since the .conf file was generated by easyengine, I don’t want to mess anything up. How would I fix this?

P.s., I already made sure the server_name included www. and I even tried the wildcard way.

@adriano-cortereal

Can you please first check if WWW subdomain has proper DNS record which is same as root-domain record or point to root-domain?

You can follow article and add necessary codes to easyengine generated conf files.

Please let me know if that works as expected for you.

I resolved by adding

server {  
        server_name "~^(?!www\.).*" ;  
        return 301 $scheme://www.$host$request_uri;  
}

to conf file for that specific domain. It now redirects all instances of www. to a non www address.

Thank you!

Glad to know that. :slight_smile:

We will handle this in easyengine soon.

You may subscribe here for future updates - http://rtcamp.com/subscribe/?newsletter-topic=nginx

Update:

I have added this issue to easyengine here - https://github.com/rtCamp/easyengine/issues/71

That;s awesome. More or less in how long do these things usually get merged and then released into a new version? I currently have the solution like I posted above but it would be nice to have it baked into ee for any future use.

We are starting work on easyengine from Monday. We have plan to release every month.

easyengine is upgradable. We will post details with release note on our blog - http://rtcamp.com/blog

You config and changes won’t get affected with upgrade.

You may watch following github issues for future updates.

https://github.com/rtCamp/easyengine/issues/74
https://github.com/rtCamp/easyengine/issues/75