Forums / General Questions / Redirect to a new domain

Redirect to a new domain

Views: 2,425

Results 1 to 4 of 4
4 Jun 2013, 6:58 AM
#1
christymreed avatar

christymreed

Zen Follower

Join Date:
May 2009
Location:
Kelso, WA
Posts:
132
Plugin Contributions:
0

Redirect to a new domain

I am "moving" to a new domain. The old domain simply (or not so simply) needs to send everyone to the new domain. The folders differ on the new domain and I am having trouble getting more than the old main page to redirect to the new domain. If people follow a search engine's link to a product page, it stays on the old domain rather than redirecting to the new domain. :no: Is there a way to add something to the header.php to redirect? If so, what's the path to the specific header.php page? :frusty: There seem to be a lot of them. :wacko:

Is there a better solution?

Thanks,
Christy

4 Jun 2013, 12:30 PM
#2
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Redirect to a new domain

christymreed:

I am "moving" to a new domain. The old domain simply (or not so simply) needs to send everyone to the new domain. ...
You may want to read the following article: I Want To Move My Zen Cart Installation.

Once the new site is live and ready to go... If the URI's are the same (just the domain change)... One can add a ".htaccess" file to the root of the old site with something like the following:

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

Later down the road, one can stop paying for website hosting and use the control panel on your DNS hosting provider to forward the old domain to the new domain. Zen Cart 1.3.9h and newer automatically generates a canonical link (unless your template removed this feature).

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

5 Jun 2013, 5:50 AM
#3
christymreed avatar

christymreed

Zen Follower

Join Date:
May 2009
Location:
Kelso, WA
Posts:
132
Plugin Contributions:
0

Re: Redirect to a new domain

What's a URI?

The issue I'm having is because the two sites were not identical. They were independent of each other. One site has existed since 2006 and is well established in the search engines. It is the site that is closing because I outgrew the domain name. The new site has been running for about a year but products were entered differently and the cart is not in the same folder as the older site. So I'm not really moving the entire site, I'm rather killing the cart but I want the domain to redirect to the new domain.

If I set up a permanent redirect for the old domain at the registrar level, it sends you to the new domain with the same old trailing address and folder and thus lands you in an error message either a 404 or 500.

It has been suggested that I do the above again but recreate my error pages to redirect to the home page.

What I'm trying to accomplish is sending customers to the new domain. Since the old site has existed for so long, search engines have oodles of links to the old pages. Rather than waste those links and miss sales, I want those links to get redirected to my new domain.

Thanks,
Christy

5 Jun 2013, 1:48 PM
#4
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Redirect to a new domain

christymreed:

... The issue I'm having is because the two sites were not identical. They were independent of each other. One site has existed since 2006 and is well established in the search engines. ... The new site has been running for about a year but products were entered differently and the cart is not in the same folder as the older site. So I'm not really moving the entire site, I'm rather killing the cart but I want the domain to redirect to the new domain. ...
As you noted - if the old and new sites do not share the same URI path + query + fragment, one cannot use a generic RewriteRule. In this case each old <=> new page mapping will need a custom redirect (or RewriteRule).

A URL is a type of uniform resource identifier (URI). Quick Example (not meant to be exhaustive or complete):

http://www.zen-cart.com/showthread.php?208441-Redirect-to-a-new-domain&p=1206124#post1206124

Some Components of the above URI.
[B]name:[/B] http
[B]authority:[/B] www.zen-cart.com
[B]path:[/B] /showthread.php
[B]query:[/B] 208441-Redirect-to-a-new-domain&p=1206124
[B]fragment:[/B] post1206124

Redirecting a URL based upon query components is complicated (default Zen Cart URLs contain these). Under Apache this can be done using RewriteRules.

# This .htaccess file should be in the document root of the old server.
# Assumes the old server will be sticking around for a suitable amount of time.
# Suitable when website forwarding does not pass URI paths or queries.

# Enable mod_rewrite
RewriteEngine on

# Zen Cart Category Example (old cPath of 1 and new cPath of 4)
RewriteCond %{QUERY_STRING} (^|&)main_page=index($|&)
RewriteCond %{QUERY_STRING} (^|&)cPath=1($|&)
RewriteRule ^/?index\.php$ http://www.newsite.com/store/index.php?main_page=index&cPath=4 [L,R=301]

# Zen Cart Product Example (old product 1 in category 1_4 and new product of 4 in category 1_5)
RewriteCond %{QUERY_STRING} (^|&)main_page=product_info($|&)
RewriteCond %{QUERY_STRING} (^|&)cPath=1_4($|&)
RewriteCond %{QUERY_STRING} (^|&)products_id=1($|&)
RewriteRule ^/?index\.php$ http://www.newsite.com/store/index.php?main_page=product_info&cPath=1_5&products_id=4 [L,R=301]
# This .htaccess file should be in the document root of the new server.
# Assumes the old server will not be sticking around.
# Suitable when website forwarding does pass URI paths or queries.

# Enable mod_rewrite
RewriteEngine on

# Zen Cart Category Example (old cPath of 1 and new cPath of 4)
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$
RewriteCond %{QUERY_STRING} (^|&)main_page=index($|&)
RewriteCond %{QUERY_STRING} (^|&)cPath=1($|&)
RewriteRule ^/?index\.php$ http://www.newsite.com/store/index.php?main_page=index&cPath=4 [L,R=301]

# Zen Cart Product Example (old product 1 in category 1_4 and new product of 4 in category 1_5)
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$
RewriteCond %{QUERY_STRING} (^|&)main_page=product_info($|&)
RewriteCond %{QUERY_STRING} (^|&)cPath=1_4($|&)
RewriteCond %{QUERY_STRING} (^|&)products_id=1($|&)
RewriteRule ^/?index\.php$ http://www.newsite.com/store/index.php?main_page=product_info&cPath=1_5&products_id=4 [L,R=301]

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker