Magento – Multi-Store with multi-domain and sub-directory Setup – Symlinks

multidomainmultistorestore-viewurl-rewrite

We have a multistore setup correctly, however I need to assign correct urls via symlinks.

  • Default Store: example.co.uk
  • Language Page: example.com
  • USA Store: example.com/us/

Under the root .htaccess I have the following:

SetEnvIf Host www\.example\.com/us/ MAGE_RUN_CODE=us_en
SetEnvIf Host www\.example\.com/us/ MAGE_RUN_TYPE=store
SetEnvIf Host ^example\.com/us/ MAGE_RUN_CODE=us_en
SetEnvIf Host ^example\.com/us/ MAGE_RUN_TYPE=store

I have also created a directory '/us/' and within I have index.php and .htaccess.

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

$mageFilename = '../app/Mage.php';
$maintenanceFile = '../maintenance.flag';
$ip = $_SERVER['REMOTE_ADDR'];

$mageRunCode = 'us';
$mageRunType = 'store';

Mage::run($mageRunCode, $mageRunType);
}

What the website is missing is the content images, css and js, I have seen that this can be achieved via symlinks now how do I go about creating that for .com/us/ folder. Please note that the root dir is:

/home/example/public_html/

Best Answer

one way to handle this would be

  1. create a public folder into your magento root
  2. inside that public folder you can create your subfolders us, nl
  3. and inside of those subfolders you can clone index.php and .htaccess files and create symlinks to ../../skin, ../../errors, ../../media
  4. at this point you can edit .htaccess freely and index.php freely to set your store scope and include the right resources and you can safely commit this to version control as you are not affecting any core files and can manage all configurations from one place.
  5. optionally you can hide the whole magento root folder out of public_html folder on your server where domain is pointed and just symlink the folders (ln -s /path/to/public/us us/) to this destination