How to Redirect a Domain to Another with htaccess

301 redirect solutions through htaccessRedirecting to your domain from another one is a good way to acquire a valuable and comparatively cheap backlink.

The easiest way to do that is through .htaccess file.

You should download it to your computer (it is usually in the root directory of your site) and edit with a text editor you like.

#redirect to your-new-site <-I prefer to keep things organized

RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]

RewriteRule ^([^/]+) $1 [L]

RewriteCond %{HTTP_HOST} !^www\.your-old-site\.com

RewriteRule ^(.*)$ http://your-new-site/$1 [R=301,L]

Small explanation -> Now, you see that you basically have to correct 2 lines here:

Rewrite condition for your site from where you redirect to your new domain -> e.g. establish a rewrite rule.

Reflecting Changes in Robots.txt

You should also correct data in your robots.txt

You can download old robots.txt from the same root directory of your old domain/site and edit again with any text editor of your choice. As follows:

User-agent: *


Don’t forget to load those two files back to the root directory of your old site and check if everything works correct. And you are done!

Do you want to get more information?

Or perhaps, you need a consultation or any other kind of help?

Leave a Reply

Other posts