I am been trying for many hrs to obtain a different store to show with different subdirectory. Our staging site setup for Magento is perfect for a Relaxation around the globe, US, United kingdom and Australian stores with assorted variations together. We've had these working by set environment variables within the .htaccess (I'll make use of the base and Australian store just for brevity), that are then utilized in the index.php file to load the right store.

SetEnvIf Host staging\.hostname\.com MAGE_RUN_CODE=base
SetEnvIf Host staging\.hostname\.com MAGE_RUN_TYPE=store

SetEnvIf Host staging-au\.hostname\.com MAGE_RUN_CODE=au
SetEnvIf Host staging-au\.hostname\.com MAGE_RUN_TYPE=website

I have now been assigned with altering this to make use of subdirectories, so staging.hostname.com/au/ , and whatever I place in does not work.

I have transformed the bottom url for that different stores within the configuration to suggest at staging.hostname.com/au/ for that Australian store. From what I can tell it isn't obtaining my new .htaccess lines of

SetEnvIf Request_URI "^/au/.*" MAGE_RUN_CODE=au
SetEnvIf Request_URI "^/au/.*" MAGE_RUN_TYPE=website

I have attempted the standard expression with and without quotes, with and with no wildcard anything (.*) with no pleasure.

Used to do ensure to remove / Comment the SetEnvIf Host lines too, as otherwise it might most likely be leading to problems as I'd set the environment variable two times.

Basically leave that old url pointing at the shop (staging-au.hostname.com) then Magento redirects towards the store's base Link to staging.hostname.com/au (to ensure that means that old .htaccess information works), however it defaults to the bottom store values and provides us a 404 error.

Any help could be greatly appreciated.

Apache version 5.2.21 in the event that helps.

It all depends how you've setup US, United kingdom etc. Presuming they're set-as stores you need to simply have the ability to enable System > Configuration > Web > URL Options > Add Store Code to Web addresses, without having to fool around together with your request_uri via .htaccess.

Or you might simply not make use of getting explicit store codes whatsoever. If you are using GEOIP to obtain the two letter country code inside your index.php you are able to the possess a simple switch/situation/if construct to create the shop code variable or website code after which call the primary program. Should you choose it this way then it's not necessary to have store codes within the URL.

$country=$_SERVER['GEOIP_COUNTRY_CODE'];
//if (isset($_COOKIE['geocountry'])) $country=$_COOKIE['geocountry'];

switch ($country)
{ case "CA": case "MX": case "US":
$_SERVER['MAGE_RUN_CODE'] = "usd";
$_SERVER['MAGE_RUN_TYPE'] = "website";
break;
  case "AT": case "BE": case "CY": case "DE": case "ES": case "FI": case "FR": case "GR": case "IE": case "IT": case "LU": case "MT": case "NL": case "SI":
$_SERVER['MAGE_RUN_CODE'] = "eur";
$_SERVER['MAGE_RUN_TYPE'] = "website";
break;
  case "BG": case "CZ": case "DK": case "EE": case "HU": case "LV": case "PL": case "RO": case "SE":
$_SERVER['MAGE_RUN_CODE'] = "eugbp";
$_SERVER['MAGE_RUN_TYPE'] = "store";
break;
  case "GB":
$_SERVER['MAGE_RUN_CODE'] = "gbp";
$_SERVER['MAGE_RUN_TYPE'] = "website";
break;
  case "AX":
$_SERVER['MAGE_RUN_CODE'] = "staging";
$_SERVER['MAGE_RUN_TYPE'] = "store";
break;
  default:
$_SERVER['MAGE_RUN_CODE'] = "row";
$_SERVER['MAGE_RUN_TYPE'] = "store";
}

Note you may need a cookie/ip or any other mechanism to in excess of-ride the geo-ip for testing reasons. You will not need different Web addresses for that different stores or different sub sites. You still have the ability to theme up each store in a different way and also have different foreign currencies in the website level.