Changing Domain Name with WordPress + Nginx

Let’s say you have a WordPress site with domain name mysite.com and you would like to change your domain name to mynewsite.com. Change the domain name is easy, but this should be done correctly or you will lose all of your SEO power.

Using 301 redirects with Nginx is the best way to accomplish the change of address.

Here is the 301 redirect code, you should but it in your server block directly after declaring your server name.

You have to add the $request_uri to the end of the domain or else Nginx will not be able to redirect any subpages.

If you want all links to redirect to the homepage (which might come in handy if you are switching to a single page parallax style site) use this.

Here’s an example Nignx server block for WordPress courtesy of DigiMix Web Design New York.

By following the official Google change of address Guidelines, you can successfully change your website URL without damaging your search engine rankings.

Matt Cutt’s has put together this nice little video to explain how 301 redirects work with search engines.


References

Nix Craft. http://www.cyberciti.biz/faq/unix-linux-bsd-nginx-rewrite-old-domain-to-new-domain/

Google Webmasters. https://support.google.com/webmasters/answer/83106?hl=en