I am trying to switch a dated Magento site in the domain root of a website I am developing (example.com) with a WordPress site located at beta.example.com. First, I want to move the Magento site to legacy.example.com in case visitors need to access it later. I simply copied all the folders from the root directory to the legacy subdomain directory.

However, when I visit legacy.example.com, it redirects me to example.com immediately. If I visit any Magento page on the legacy subdomain it redirects me to example.com (the default index) as well. However, if I visit an independent HTML page that I made such as legacy.example.com/index.html the subdomain does not redirect.

I looked at the .htaccess file located in the main directory for example.com (I copied it to the legacy subdomain along with all the other Magento files) but I can't figure out what exactly is causing the redirect.

How can I find out what exactly is causing the redirect here? The WordPress site located at beta.example.comdoes not have any redirect issues. What is the problem with the Magento site?


Deleting the entire .htaccess file in the legacy subdomain does not affect the redirect. Is it possible that index.php redirects? I couldn't find a redirect myself in the code shown below:

 * Magento
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 * @category   Mage
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)

if (version_compare(phpversion(), '5.2.0', '<')===true) {
    echo  '<div style="font:12px/1.35em arial, helvetica, sans-serif;">
<div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
<h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">
Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer.
<a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a>
 Magento using PHP-CGI as a work-around.</p></div>';

 * Error reporting
error_reporting(E_ALL | E_STRICT);

 * Compilation includes configuration file
define('MAGENTO_ROOT', getcwd());

$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
if (file_exists($compilerConfig)) {
    include $compilerConfig;

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';

if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename." was not found";

if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';

require_once $mageFilename;



#ini_set('display_errors', 1);


/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run($mageRunCode, $mageRunType);
  • Since all requests (for non-existent / Magento files) go through the front controller (index.php) I would guess that it is Magento itself that is perhaps triggering the redirect? – MrWhite Aug 30 '15 at 11:44
  • As well, I would like to warn you and anyone that simply copying an .htaccess from a parent domain to a sub-domain will often not work without modification depending on the code of course. Many times, using an .htaccess file from a CMS or other similar install is not immediately transferable to a sub-domain at least. – closetnoc Aug 30 '15 at 16:41
  • Is it easy enough to figure out what I need to change or will I need a lot of background knowledge of PHP/.htaccess files? I didn't see any redirects that I could tell in index.php but I could post that too if that would help. – intcreator Aug 31 '15 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.