Positive Vibes to your Inbox

An occasional newsletter to brighten your inbox, bringing you the best thoughts and links from the studio


Changing a website domain name using htaccess

In this blog post, I discuss the process of moving a website, incase it’s of any use to anyone doing a similar thing…

I recently renamed my company from AD Digital Ltd, which was always intended as a temporary name, to styles.studio. The website’s content remained mostly unchanged, except for the company name. I aimed to keep the same website but switch to a new URL.

Instead of forwarding from the new URL to the old one, which would leave traces of the old URL, I decided to copy the site locally and then upload it to a new server for styles.studio. Once everything was operational and the import completed, I needed to redirect from the old URLs to the new ones. Although DNS-level forwarding is an option, it fails with HTTPS because the DNS doesn’t recognise the security certificate.

To solve this, I explored various methods and found that, as both the new and old sites were exactly the same, using a .htaccess file on the server root was most effective. By updating it with a regex redirection, any URL on the old site would be redirected to the new URL automatically. For instance, a-d.digital/about would redirect to styles.studio/about seamlessly.

This is the code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^a-d\.digital$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.a-d\.digital$ [NC]
RewriteRule ^(.*)$ https://styles.studio/$1 [L,R=301]

After setting up these redirections, it’s crucial to configure Google Search Console. Informing Google of the URL change ensures that 301 redirections are active. A 301 redirection is permanent and transfers about 90% of your old site’s SEO benefits to the new one.

Now, I’m in the process of updating references to the old URL on platforms like LinkedIn and Instagram. While not essential due to redirections, it’s beneficial for accuracy when changing your business name. That’s where I’m at currently.