When migrating your website to a new domain, setting up redirects is essential to preserve your SEO value. This article explains the necessary redirect settings and provides examples of how to write 301 redirects in the .htaccess file when migrating your website.
The Importance of SEO When Migrating a Website
When migrating a website to a new domain, many people struggle with how to maintain their SEO rankings. To transfer the credibility and rankings accumulated by the old site to the new site, proper redirect settings are necessary. If you neglect this step, the new site will essentially start from scratch, putting all your previous SEO efforts at risk.
Prerequisites for Setting Up Redirects
Before setting up redirects, make sure that your web server is running Apache and that the mod_rewrite module is enabled. Without this, you won’t be able to configure redirects using .htaccess.
Redirect All Pages to a Specific Page on the New Site
If you want to redirect all URLs from the old site to a specific page on the new site (such as a sitemap page), configure your .htaccess file like this:
RewriteEngine On
RewriteRule ^(.*)$ https://dad-union.com/sitemap [R=301,L]
With this configuration, all pages on the old site will be redirected to the specified page on the new site.
In this example, all pages will be redirected to the “https://dad-union.com/sitemap” page.
When the Old and New Sites Have the Same Directory Structure
If the old and new sites share the same directory structure, configure your .htaccess file like this:
Redirect permanent / https://dad-union.com/
This method is the most recommended from an SEO perspective. Each page will be accurately redirected to the corresponding page on the new site.
Redirecting Specific Pages to Different Directories
If some pages have different directory structures between the old and new sites, you can add specific rules for those pages in your .htaccess file (line 2).
For all other pages, they will be redirected to “https://dad-union.com/sitemap” as defined on line 3.
RewriteEngine on
RewriteRule ^olddir/page.html https://dad-union.com/newdir/page.html [R=301,L]
RewriteRule ^(.*)$ https://dad-union.com/sitemap [R=301,L]
In this example, only specific old pages are redirected to specific pages on the new site, while all other pages are redirected to the sitemap page.
Summary
When migrating a website to a new domain, setting up proper redirects is essential to maintain your SEO rankings. Use the methods introduced in this article to set up appropriate redirects and minimize the impact on SEO. Website migration can be a complex and time-consuming process, but with the right knowledge and techniques, it can be carried out smoothly.
*Please use this information at your own risk.*