Zen Cart Logo
Forums / General Questions / Forwarding from old shop to new?

Forwarding from old shop to new?

Locked

Views: 3,440

Results 1 to 20 of 22
This thread is locked. New replies are disabled.
6 Nov 2008, 4:18 PM
#1
nonfinite avatar

nonfinite

Zen Follower

Join Date:
May 2008
Posts:
203
Plugin Contributions:
0

Forwarding from old shop to new?

I recently created new web shop, http://nonelectronics.com/catalog, based on an old shop, http://nonfinite.org/catalog.

I want anyone following a link to old products at nonfinite.org/catalog to automatically forward to the same product at nonelectronics.com/catalog.

Is this possible? If so, how do I implement this change?

If it isn't, is there at least some way I can have all pages from the old shop forward to the nonelectronics main page, nonelectronics.com?

6 Nov 2008, 4:47 PM
#2
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: Forwarding from old shop to new?

Two ways, the first is BEST and most efficient!

  1. Have your DNS provider Forward all requests from domain 1 to domain 2
  2. A temporary solution would be to create an index.html or default.html and place it in your document root with something like this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>nonelectronics.com/</title>
<meta http-equiv="REFRESH" content="0;url=http://www.nonelectronics.com/catalog"></HEAD>
<BODY>
If our new site does not load in 5 seconds <a href="http://www.nonelectronics.com/catalog"> Please Click Here </a>!
</BODY>
</HTML>

adapt it as you need to work for you. It's the REFRESH tag that does all the work for you and most 21st Century browsers will auto re-direct. Search engines may just forget you though.

The DNS change is still your best bet.
JOhn ><>

6 Nov 2008, 4:49 PM
#3
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: Forwarding from old shop to new?

I see you already did option 2, now try option 1
JOhn ><>

6 Nov 2008, 6:12 PM
#4
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: Forwarding from old shop to new?

Here is a suggestion

<?php
// index.php on old site
// Get the requested page and redirect to new site url

   header('HTTP/1.1 301 Moved Permanently');
   header('Location: http://nonelectronics.com/catalog/'.basename($_SERVER['REQUEST_URI']));

?>
6 Nov 2008, 6:15 PM
#5
nonfinite avatar

nonfinite

Zen Follower

Join Date:
May 2008
Posts:
203
Plugin Contributions:
0

Re: Forwarding from old shop to new?

The issue with option 1 would be that non-shop portions of nonfinite.org would go to dead space at nonelectronics.com...

Is it possible to forward just http://nonfinite.org/catalog/xxx urls to it's counterpart, http://nonfinite.org/catalog/xxx, or is it all or nothing? For example, nonfinite.org/gallery takes you to nonelectronics.com/gallery = bad.

6 Nov 2008, 6:35 PM
#6
nonfinite avatar

nonfinite

Zen Follower

Join Date:
May 2008
Posts:
203
Plugin Contributions:
0

Re: Forwarding from old shop to new?

skipwater, your solution worked perfectly. Thank you! :clap:

11 Nov 2008, 9:01 PM
#7
countingsheep avatar

countingsheep

Zen Follower

Join Date:
Sep 2006
Posts:
154
Plugin Contributions:
0

Re: Forwarding from old shop to new?

skipwater:

Here is a suggestion

<?php // index.php on old site // Get the requested page and redirect to new site url header('HTTP/1.1 301 Moved Permanently'); header('Location: http://nonelectronics.com/catalog/'.basename($_SERVER['REQUEST_URI'])); ?>
 
 
Is this needed on every page of the old cart? Or where does this go? Sorry for my ignorance.
12 Nov 2008, 12:07 AM
#8
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Forwarding from old shop to new?

Put this portion in the index.php which should be placed where ever the old cart was placed.

16 Nov 2008, 6:28 PM
#9
countingsheep avatar

countingsheep

Zen Follower

Join Date:
Sep 2006
Posts:
154
Plugin Contributions:
0

Re: Forwarding from old shop to new?

yellow1912:

Put this portion in the index.php which should be placed where ever the old cart was placed.

Thank you very much! It worked great!

13 Dec 2008, 6:54 AM
#10
gjh42 avatar

gjh42

Black Belt

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

Re: Forwarding from old shop to new?

I am moving our site from /shop/ to the root, and trying this 301 redirect method. I renamed the old ZC index.php to index.php.zc137.bak, and put this file in as index.php:```php

<?php // index.php on old site // Get the requested page and redirect to new site url // from skipwater - modified by gjh42 20081212 header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.futurelics.com/'.basename($_SERVER['REQUEST_URI'])); ?>

The old address is <http://www.futurelics.com/shop/>
and the new  is <http://www.futurelics.com/>

Any ideas why this is not working?
13 Dec 2008, 7:00 AM
#11
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Forwarding from old shop to new?

You can use htaccess to do that.

But using php is fine as well, did you try to echo

"http://www.futurelics.com/'.basename($_SERVER['REQUEST_URI']"

and see what is echoed out? Can be something really weird

13 Dec 2008, 7:46 AM
#12
gjh42 avatar

gjh42

Black Belt

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

Re: Forwarding from old shop to new?

It won't echo in that file. It causes a "headers already sent" error if put at the beginning, and the same redirect loop if at the end:```php

<?php // index.php on old site // Get the requested page and redirect to new site url // from skipwater - modified by gjh42 20081212 header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.futurelics.com/'.basename($_SERVER['REQUEST_URI'])); echo 'http://www.futurelics.com/'.basename($_SERVER['REQUEST_URI']); ?>
13 Dec 2008, 7:50 AM
#13
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Forwarding from old shop to new?

You have to comment out the 2 header commands first if you want to echo anything there :) > gjh42:

It won't echo in that file. It causes a "headers already sent" error if put at the beginning, and the same redirect loop if at the end:```php

<?php // index.php on old site // Get the requested page and redirect to new site url // from skipwater - modified by gjh42 20081212 header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.futurelics.com/'.basename($_SERVER['REQUEST_URI'])); echo 'http://www.futurelics.com/'.basename($_SERVER['REQUEST_URI']); ?>
13 Dec 2008, 8:06 AM
#14
gjh42 avatar

gjh42

Black Belt

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

Re: Forwarding from old shop to new?

It's echoing apparently just what it should:

http://www.futurelics.com/shop

which is what the address bar is calling for:

http://www.futurelics.com/shop/

13 Dec 2008, 8:23 AM
#15
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Forwarding from old shop to new?

Correct me if Im wrong, but shouldnt you have:

 header('HTTP/1.1 301 Moved Permanently');
   header('Location: http://www.futurelics.com/'.$_SERVER['QUERY_STRING']);

Something like that

13 Dec 2008, 8:28 AM
#16
gjh42 avatar

gjh42

Black Belt

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

Re: Forwarding from old shop to new?

I didn't write the code, I just copied it from skipwater's post, which apparently worked for others. Server info is outside my area of experience.

Now the echo is

http://www.futurelics.com/

for address bar

http://www.futurelics.com/shop/

13 Dec 2008, 8:32 AM
#17
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Forwarding from old shop to new?

The uri will have your subfolder included, so for example you are visiting

site.com/sub/something

then the code above will actually try to redirect you to the same address, which will then again redirect you the same address again.

The above code works only in case you change your domain name and still have the same folder structure,, and you want to redirect customers to new domain. Your situation is different, you are on the same domain, you changed your folder structure, you can try my suggested code to see if it does what you want.

13 Dec 2008, 8:35 AM
#18
gjh42 avatar

gjh42

Black Belt

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

Re: Forwarding from old shop to new?

Now it is redirecting correctly. Thanks for your help!

13 Dec 2008, 10:02 AM
#19
gjh42 avatar

gjh42

Black Belt

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

Re: Forwarding from old shop to new?

Spoke too soon - individual product pages are not redirecting correctly. This page is #2 on the first page of the google search for oak leaf earrings, but now fails to resolve correctly:
https://www.futurelics.com/shop/index.php?main_page=product_info&cPath=90&products_id=60

It displays as

ww w.futurelics.com/main_page=product_info&cPath=90&products_id=60

(gap added) losing the

index.php?

What would get that part of the address back? Would a rewrite rule in .htaccess be more reliable?

13 Dec 2008, 10:38 AM
#20
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Forwarding from old shop to new?

Easy enough

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.futurelics.com/index.php?'.$_SERVER['QUERY_STRING']);

Something like that, you can even add an "if" to check if the query_string is empty, if it is empty then redirect to home page

Something like this:

$qstring = !empty($_SERVER['QUERY_STRING']) ? '/index.php?'.$_SERVER['QUERY_STRING'] : '';

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.futurelics.com'.
$qstring);