Hello,
I have a customized php script in my index.php that sets the store view based on geoip. I've tried modifying this so that it works with a few seperate sites based on the URL that is typed in, however I cannot get a sub-sub domain to work as desired.
Here is the code:
$urlis = $_SERVER['REQUEST_URI']; if ($_SERVER['REQUEST_URI'] == "/") { include("/home/mystore/public_html/skin/frontend/default/theme/geoip/geoip.inc"); $gi = geoip_open("/home/mystore/public_html/skin/frontend/default/theme/geoip/GeoIP.dat",GEOIP_STANDARD); // Exact file path must be used!!! $ip = $_SERVER['REMOTE_ADDR']; $country_code = geoip_country_code_by_addr($gi,$ip); if (strpos($urlis,'dev') === TRUE) { if (strpos($urlis,'wholesale') === TRUE) { if ($country_code == "CA") $_SERVER['MAGE_RUN_CODE'] = 'wholesale_ca'; if ($country_code == "USA") $_SERVER['MAGE_RUN_CODE'] = 'wholesale_us'; } else { if (strpos($urlis,'dev') === TRUE) { if ($country_code == "CA") $_SERVER['MAGE_RUN_CODE'] = 'mystore_canada_store_view'; if ($country_code == "USA") $_SERVER['MAGE_RUN_CODE'] = 'mystore_usa_store_view'; }}} else { if ($country_code == "CA") $_SERVER['MAGE_RUN_CODE'] = 'mystore_canada_store_view'; if ($country_code == "USA")$_SERVER['MAGE_RUN_CODE'] = 'mystore_usa_store_view'; } }
The main problem is that if I go to :
dev.mystore.com it works as expected, if I go to store.com it works as well, however if I attempt to go to wholesale.dev.mystore.com it forwards to dev.mystore.com .
I've tried also changing the URL detection to wholesale.dev no go, reversed the order (and generally placed the if/else statements both inside and outside each other, but to no avail.
I know it's a logic problem with my IF statements, but for the life of me, I cannot find it...
suggestions/help are welcome.
Cheers!
Ok,
So it looks like my detection code isn't working. I've modified my code to the following, and ONLY the last else statement works.
$urlis = $_SERVER['REQUEST_URI']; if ($_SERVER['REQUEST_URI'] == "/") { include("/home/mystore/public_html/skin/frontend/default/theme/geoip/geoip.inc"); $gi = geoip_open("/home/mystore/public_html/skin/frontend/default/theme/geoip/GeoIP.dat",GEOIP_STANDARD); // Exact file path must be used!!! $ip = $_SERVER['REMOTE_ADDR']; $country_code = geoip_country_code_by_addr($gi,$ip); if (strpos($urlis,'wholesale') === TRUE){ if ($country_code == "CA") $_SERVER['MAGE_RUN_CODE'] = 'wholesale_ca'; if ($country_code == "USA") $_SERVER['MAGE_RUN_CODE'] = 'wholesale_us'; } elseif (strpos($urlis,'dev') === TRUE) { if ($country_code == "CA") $_SERVER['MAGE_RUN_CODE'] = 'wholesale_ca'; if ($country_code == "USA") $_SERVER['MAGE_RUN_CODE'] = 'wholesale_ca'; } else { if ($country_code == "CA") $_SERVER['MAGE_RUN_CODE'] = 'wholesale_ca'; if ($country_code == "USA")$_SERVER['MAGE_RUN_CODE'] = 'wholesale_us'; } }
Any suggestions?
Anybody ?