logo

htaccess redirect from one site to another

logo

Whether your idea failed or you’re just not feeling the magic with an old website you may want to take advantage of the SEO you have done by passing this onto another website.

By now you probably already know about 301 redirects and how they can pass on the PR and link juice from the old page, but what about if you want to redirect an entire site using an htaccess?

For the argument of this article let’s say the site we are redirecting from is called siteX.com

Normally you would see the htaccess redirect looking something like this for siteX.com to redirect to somesite.com:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.somesite.com/$1 [R=301,L]

This will work to some degree however when users are accessing internal pages from sitex.com (through old google indexing or something) this will cause problems if these internal pages don’t exist on the new site you are redirecting too!

If you visited www.sitex.com/coolpage.html you would be redirected to www.somesite.com/coolpage.html which may not be what you are after if this page doesn’t exist.

A way around this? Change your htaccess to this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.somesite.com/ [R=301,L]

Now if you were to visit www.sitex.com/coolpage.html you would simply be redirected to www.somesite.com which would also receive any link juice and PR that was poiting to sitex.com/coolpage.html

I hope this helps some people!

Leave a Reply

logo
logo
Powered by Wordpress | Designed by Elegant Themes