Forums / General Questions / Use 301 redirects to forward old site to new

Use 301 redirects to forward old site to new

Views: 1,244

Results 1 to 5 of 5
13 Oct 2011, 6:58 PM
#1
feznizzle avatar

feznizzle

Totally Zenned

Join Date:
Apr 2010
Posts:
900
Plugin Contributions:
0

Use 301 redirects to forward old site to new

Hi!

I'm writing for 2 reasons. First is to share something I think is really cool. Second is to see if anyone can add to it.

Ok, what I figured out is how to put a 301 redirect into my htaccess file that would redirect the entire site to a new domain. Simply open the htaccess file and, at the top, put in the following single line:

redirect 301 / http://www.NEWsite.com/

Just like that you are done! This will create search engine friendly URL redirects. If you have to move domains and you want to keep your google rankings, this is the way to go!

This is what will happen:
https://www.OLDsite.com/category_I_want_to_keep
301 redirected to
https://www.NEWsite.com/category_I_want_to_keep

https://www.OLDsite.com/productURL_I_want_to_keep
301 redirected to
https://www.NEWsite.com/productURL_I_want_to_keep

Obviously your sites have to be structured the same. I use Ceon URI and SitemapXML. The only thing that changed was my domain name, so this worked beautifully.

Hope this helps!
Mike

13 Oct 2011, 7:05 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Use 301 redirects to forward old site to new

This is also a good technique for the situation where you move your Zen Cart on the same server, such as from a subfolder to the root.

13 Oct 2011, 7:11 PM
#3
feznizzle avatar

feznizzle

Totally Zenned

Join Date:
Apr 2010
Posts:
900
Plugin Contributions:
0

Re: Use 301 redirects to forward old site to new

Oh... how to improve this?

I would like my entire site to 301 redirect, EXCEPT the index.php and the /About_Us page. This site is now owned by a different company and they want no affiliation with the old.... except the well ranked links.

In fact, I would like to put up a index.html file so that if somebody comes to https://www.OLDsite.com, they will see the message on my index.html.

Can somebody maybe explain how to add some exceptions to the htaccess rule above?

Thanks,
Mike

13 Oct 2011, 10:06 PM
#4
conor avatar

conor

Passed

Join Date:
Aug 2004
Location:
Belfast, Northern Ireland
Posts:
2,480
Plugin Contributions:
4

Re: Use 301 redirects to forward old site to new

Hi,

You could probably use:

RewriteEngine On
 
RewriteCond !^/index.html$ [NC]
RewriteCond !^/index.php$ [NC]
RewriteCond !^/About_us [NC]
 
RewriteRule .* [URL]http://www.NEWsite.com/[/URL] [QSA,L]

This isn't really my area though.. just helping because you asked. :)

All the best...

Conor
ceon

NOTE: We are sorry that Conor is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

13 Oct 2011, 11:58 PM
#5
feznizzle avatar

feznizzle

Totally Zenned

Join Date:
Apr 2010
Posts:
900
Plugin Contributions:
0

Re: Use 301 redirects to forward old site to new

Thanks Conor.