Updating Domains with Cloudways • 301 Redirects

[read_meter]

Table of Contents

So you’re updating domains, but what about your search rankings? I just did this myself and it wasn’t as hard as I expected.

Disclaimer, if you need help, read .htaccess file and SSH setup.

1. HTACCESS File

If you’re running a Content Delivery Network (CDN), turn off caching. For example, Cloudflare Dashboard > turn on development mode.

Next, connect to your server via SSH.

  1. ssh <username>@<ip>
  2. nano .htaccess
  3. Copy the text below, replace the placeholder text.
  4. Exit nano and save file, CTRL + X > Y > ENTER

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^olddomain.com$
  RewriteRule (.*)$ <https://newdomain.com/$1> [R=301,L]
</IfModule>

Done, you’ve added code to force the redirect of your new domain on all web pages.

2. WordPress

Now reflect the new domain in WordPress.

Go to, Settings > General > WordPress Address (URL), Site Address (URL) and add your new domain to either both fields or site address.

https://p146.p4.n0.cdn.getcloudapp.com/items/qGu7vGmO/515fb4f4-b80f-4701-bef6-1085aead738e.jpeg?v=c880891c70243b6ec38596bc3261be1c

Easy as, that’s it for WordPress.

3. Cloudways

Now the server and WordPress application know about the changes, it’s over to your web host.

  1. Cloudways > Application Management > Domain Management
  2. Update Primary Domain to New Domain
https://p146.p4.n0.cdn.getcloudapp.com/items/E0ugrv1E/b92d1c56-3a6c-4e8c-ba9a-b2ee86879a68.jpeg?v=26f0f0c7ac2390d135dbcfea3d26107a

If you’re stuck, reach out to the Cloudways support team, they’re super helpful. If you host with another provider, check their documentation for these steps.

4. Search Engines

Lastly, to ensure your precious Search Rankings stay as they are, update your desired Search Engine Consoles.

  1. For Google, Search Console > select your old domain.
  2. Go to Settings > Change of address

For more see How do I safely move or migrate my website to a new domain name?

Now repeat this for the other search engines such as Bing… or don’t. Hope this was helpful.

About The Author
Mr Ash

Mr Ash

“Learn, create, share, repeat.” • IT teacher, former web designer, learning CyberSec • Road to #100DaysOfHacking on Hackers Learning Path.
Share This Article
LinkedIn
Twitter
Facebook
WhatsApp
Email

Monthly Newsletter

Learn about cyber security, hacking guides & python programming.

Leave A Comment

2 Responses

  1. Hi Ash, nice guide. Just a quick question, what would you say to completing the first step in your guide at the DNS level, by using Cloudflare to perform the 301 redirect from old to new domain? Also, I think you’ll find that when completing step 3 in your guide, Cloudways updates the WordPress URL for you (removing the need to do step 2)

    Lastly, I’d recommend adding in a step to do a search and replace of the old url in the database, often there are references to it that are missed by the WordPress script.

    Anyway, great guide 🙂

    1. Hi Alex,

      I haven’t tried performing full site 301 redirects at the DNS level, it’s something I’ll look into!

      Thanks for taking the time to leave a comment, I appreciate it.

      Kind regards,
      Ash

Leave a Reply

Your email address will not be published.

More Content

Monthly Newsletter

Learn about cyber security, hacking guides & python programming.

This site uses cookies and other tracking technologies to assist with navigation, monitor site usage and web traffic, assist with our promotional and marketing efforts, and customize and improve our services, as set out in our privacy policy