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

  • akadir60

    hello Joshua can you write me your g-mail address ı need to ask you a few questions, please write to me, usluabdulkadir60@gmail.com

  • Hey Joshua, it all depends on how you have set up your Nginx configuration. However, if you are working with a default configuration, you would modify you’re site’s available configuration file.

    By default on Ubuntu you the file would be /var/etc/nginx/default.

    It’s likely that you or a developer has modified the fault config file, in which case you would add it too which ever is active for the site you are working on.

    More advance Nginx configurations separate the various config directives into multiple files. So in that case you would have to post your example in order for us to answer your question more specifically.

    Hope this helps!