I have a magento store but currently decided to add other stores to separate the inventory and also have a clean catalog so i decided to create stores and host them on sub-domains like electronics.mydomain.com
and sport.mydomain.com
. i followed this tutorial http://www.crucialwebhost.com/blog/how-to-setup-multiple-magento-stores/ but after it the sub-domains were still redirecting to main domain like www.mydomain.com even though i had done nothing with my .htaccess, i found a way to go about it by opening the index.php in my subdomain directory and adding $_GET['___store']= "STORECODE";
and also in my admin panel i typed .mydomain.com in the cookie field and also prolonged the duration to 1 day.
Voila.. everything is working now perfectly until i realized there was a problem, whenever i visit any of my stores(which is installed on the subdomain) and then try to open my main domain that is the www.mydomain.com
, it redirects to subdomain.mydomain.com
(which is the url of the last subdomain i checked) but then it works again after clearing cookies, i realized the problem is that magento is saving the current store id in the cookie so when i opens my main domain and the cookie is read, that store is returned and therefore the redirect.
Okay , now i have been able to remove the SID from the url and everything works as they share the same cookie domain, now i noticed if i accessed my link like welspot.com?_store=default, the main site opens without a redirect to the subdomain, i was hoping then that anybody could help me redirect all incoming requests under my main domain to mydomain.com?_store=default.
As i still have the problem of cookie redirect, i have hard-coded $_GET['store']="default";
into my index.php file at the head in the main magento installation and now everything works right but there is another problem, when i go to the categories field and i try to select any categories it doesn't select, it just displays create new category instead of selecting and editing the click category and i think it has something to do with adding $_GET['store']="default";
in my index.php because when i remove it everything works but when i remove it and visit my site as welspot.com, based on the recent subdomain i visited it redirects there and i seriously need to solve this problem.