elboriyorker
07-13-2024, 02:24 AM
When you migrate a site from one domain to another, it is very important that you don’t break all the links that you built to your old domain. Proper redirection of all the pages on the old domain to the same location on the new domain will ensure that visitors to the old domain will end up in the right place. A failure to redirect will result in a loss of visitors as well as search engine rankings.
We are assuming that your web server uses Apache for the purpose of this tutorial. If you have not made any changes to your overall site structure, but have simply relocated the site in its current state, you can add the following lines to your .htaccess file located at the root of your old domain:<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule>
If you have made changes to your site structure, you can still use the lines above on your old domain, but you will also need to create redirects in the .htaccess file on your new domain to handle the specific site changes.
To redirect a single page to a new location on the same domain, use the following syntax:
Redirect 301 /old/old.htm http://www.domain.com/new.htm
We are assuming that your web server uses Apache for the purpose of this tutorial. If you have not made any changes to your overall site structure, but have simply relocated the site in its current state, you can add the following lines to your .htaccess file located at the root of your old domain:<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule>
If you have made changes to your site structure, you can still use the lines above on your old domain, but you will also need to create redirects in the .htaccess file on your new domain to handle the specific site changes.
To redirect a single page to a new location on the same domain, use the following syntax:
Redirect 301 /old/old.htm http://www.domain.com/new.htm