Skip to main content

Things to remember when you change the domain name of your Drupal website

As you may have noticed, my domain name is now I've been wanting to change my domain name for some time now, for many reasons. People are often surprised that .xyz is a legitimate domain name despite Plus, If it weren't for my friends, this change would never have happened. They, very astutely, pointed out that it sounds like the domain name of a porn site.

Anyway, that's not the point of this article. There are some very important things to keep in mind when you have permanently changed your domain name. The most important thing is to tell everyone that you have a kick-ass new domain that spells your first name exactly as it is! Like But this is one of the first changes to come. I have been disappointed with many aspects of my website for a long time and have no time to do anything about it. But I hope in the coming days I can snazz up my website and also add some more content.

After you are done telling everyone about your snazzy new domain name, you have to: 

  1. Add the A records in your domain manager to point to your server's IP address.
    • In my case, I just added two records: and I don't use the www part, I just keep it for nostalgic and legacy reasons. There was a time when every website was There was a nice ring to it. It sounded like a proper website. Here's an interesting article on what I'm going on about: Do you really need www.
  2. Set up a redirect in your server. You can do this in two ways, AWS Lambda or plain nginx/apache redirect. 
    • I use apache and here's what my redirect looks like: 
      <VirtualHost *:80>
         RedirectMatch ^/(.*)$$1
    • The I edited my old VirtualHost config file and created a new one and deleted the ssl one so that I can re-create it using Let's Encrypt. Just do sudo certbot --apache
  3. Edit your settings.php file and change base_root, trusted host patterns etc. The most easy way to do this is to grep your old domain name.
    • grep -rn 'abhaisasidharan' /path/to/setings.php
  4. Edit your services.yml file and change cookie domain name. If you have something else in it, please do that too. Grep is your best friend. 
  5. Last but not least, google search and seo. 
    • If you are not using Google Search Console, use it! It's your other best friend that you see once and forget about, but still gives you the attention you need.
    • If you have already setup google search console:
      • Add a new property and enter your new domain name
      • Verify the domain by adding the TXT records they provide. It might take a few minutes to a couple of hours for the TXT records to be available.
        Google Search Console verification
      • After that, add your sitemap.xml url.
      • Almost done. Now you have to let google search console know that you have moved the website. For this, go to your original property, click on settings, and you will see the option to move site. You will see the below screen once you click and verify it.
        Google Search settings

And that's all the stuff I can think of when moving your website. If anyone notices something I missed, please comment below and I will make that edit on this article as well as do it myself.


Share this post