Move your Zencart store to a new domain/subfolder – SEO Tip
|This is a very common issue, as much as you would try to avoid doing it, sometimes you have to move your zencart folder somewhere else, either to a new subfolder or to a new domain. In such cases, it is very important to redirect all visits to the old links to the new locations.
Below is a nice snippet that will help you accomplish the dirty job.
// index.php on old site
// Get the requested page and redirect to new site url
// from skipwater - yellow1912 - gjh42 20081213
$new_domain = "www.mynewsite.com"; // if you do not change domain, simply enter the current domain here
/**
* example 1:
* site: http://www.mynewsite.com -> $new_store_path = "";
*
* example 2:
* site: http://www.mynewsite.com/sub1/sub2 -> $new_store_path = "sub1/sub2/";
*
* example 3:
* site: http://www.mynewsite.com/sub1 -> $new_store_path = "sub1/";
*/
$new_store_path = "store/";
// do not edit code below
$request_type = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == '1') || (isset($_SERVER['HTTP_X_FORWARDED_BY']) && strstr(strtoupper($_SERVER['HTTP_X_FORWARDED_BY']),'SSL')) || (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && strstr(strtoupper($_SERVER['HTTP_X_FORWARDED_HOST']),'SSL')) || (isset($_SERVER['SCRIPT_URI']) && strtolower(substr($_SERVER['SCRIPT_URI'], 0, 6)) == 'https:') || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ) ) ? 'http' : 'https';
$qstring = ($_SERVER['QUERY_STRING'] != '') ? '?'.$_SERVER['QUERY_STRING'] : '';
header('HTTP/1.1 301 Moved Permanently');
header("Location: {$request_type}://{$new_domain}/{$new_store_path}{$qstring}");
Place the snippet above in your oldsite/path-to-zencart/index.php (you should rename the current index.php to index.php.back and create a new index.php file just for this purpose).