IMPORTANT! This has been updated, please see post below on how to set it up...
Hi there,
I have two stores set up under one website and it was all going smoothly. Nice being able to share the shopping cart, have different tracking, new design etc.
However, if I go directly to the URL without having selected the correct store I get a 404 error. So for instance:
If I then switch to the Jeans Store and enter the same URL that failed last time then it is fine as that product is contained within the Jeans Store. If however I enter the first URL for the shoe product, this still works, but using the Jeans Store template.
My concern is that if someone has visited my website before and click on a link from a search engine, then they will receive a 404 error if they have been in a different section of the site even though the product/category exists.
I tried to set it up using subfolders but had the same problem?!?
Can anybody help or tell me what I’m doing wrong? It seems odd to me, as I would believe the scope for the URLs is per website as the shopping cart is.
I have also noticed that when I go to the generated site map it only list products from the first store of the website no matter which store I may happen to be in?
Me bigging silly, the site maps generate per store. This still seems weird to me as I have ‘two stores’ under one ‘website’. I would want my sitemap to show the 2 stores on the same sitemap?!?
This has also been a concern of mine as well. The reason that you are receiving a 404 is because Mage is running the “default” store. If you notice when you use the store switcher, you will see /?store=new_store_name appended to the initial url. Once you navigate to the first product and/or category in that store it drops the appended store modifier and you browse as normal. Yes, multi-store functionality is nice but I don’t know how it will function in search engine spidering, bookmarking etc. To see what I mean, try adding /?store=your_store_name to the end of the url that returns a 404. I wish I knew a good fix for this, but I don’t.
OK, well finally I worked this out. In my case the easiest way was to add my store as a sub directory. So here’s what I did for those having the same problem.
- Create a new directory in the main web directory (for example /store2 - bear in mind that I have Magento installed in the root web directory, not in a folder).
- Copy over the main index.php file and the .htaccess file into this new folder.
- Amend the index.php file: change $mageFilename = app/Mage.php’; to $mageFilename = ‘../app/Mage.php’; and then change Mage::run(’default’); to Mage::run(’store2_uk’);. The run command should point to the default store view for the new store. So it means that when someone goes to http://www.mywebsite.com/store2/ they will then get the default store view which in this example is store2_uk
- Now update the .htaccess file in this directory. Set RewriteBase to the new directory’s name, so in this case we would use RewriteBase /store2/.
Creating the new store in the admin is done by going to System->Manage Stores. You should already have a website set up, one store and one store view. Think of the website as the whole environment for sharing things like the shopping cart, user accounts etc., the store as a way of combining separate stores under one main website (e.g. your website could be selling fashion, and you may have 3 stores: a clothes store, a shoe store, and an accessories store that are all under the same website brand), and a store view as a skin for the individual store (good for design changes and language changes).
- So create a new store and then choose the main website from the Website dropdown, give it a name e.g. Store 2, choose a root category (you should have a separate root category for the store e.g. shoes).
- Create your default store view for the new store and choose your new store (e.g.Store 2) from the store dropdown, give it a name (e.g. UK Store 2), then give it a code of store2_uk (this is the name that is referenced by the Mage::run(’store2_uk’) in our index.php file), set the status to enabled and if you want to add lots of store views you can order their display order with the final box.
You can now change all the configuration settings for this new store, but to get it working you will need to go to System->Manage Configuration.
- From Current Configuration Scope: in the top left, choose your new store view (e.g. Store 2 -> UK Store 2). Now choose Web from the General box situated in the menu on the left.
Below we will just address sites without SSLs so will only amend the unsecure section, but you can use the example for secure settings too (you’d just need to use your secure domain):
- Untick the Use Website box next to Base URL and enter your website URL (with a forward slash at the end) e.g. http://www.mywebsite.com/
- Now to get everything to work with the new store simply untick the Use Website box next to Base Link URL and enter the name of your new directory at the end e.g. {{unsecure_base_url}}store2/.
Now go to http://www.mywebsite.com/store2/ and you should see your new store view (you may need to build a home page for it). All urls should now also work and change the store accordingly, so you will not need ’?store=‘ at the end of the URL.
This has also been a concern of mine as well. The reason that you are receiving a 404 is because Mage is running the “default” store. If you notice when you use the store switcher, you will see /?store=new_store_name appended to the initial url. Once you navigate to the first product and/or category in that store it drops the appended store modifier and you browse as normal. Yes, multi-store functionality is nice but I don’t know how it will function in search engine spidering, bookmarking etc. To see what I mean, try adding /?store=your_store_name to the end of the url that returns a 404. I wish I knew a good fix for this, but I don’t.
Hi Wiseguy,
Thanks for this. I did something v.similar to get another store working b4 coming across this post - the 2 things different for me was that I didn’t change the RewriteBAse rule in .htqaccess - mine is # commented & adding /mystore2/ leads to an apache ‘object not found’. This could be due to my second difference - in the base url I put the full path to the new store - so mine was http://localhost/magento/store2/ .
What I haven’t achieved yet is the following - on the default demo store there is the site switcher drop down. My store2 is referenced in my default store site switcher. Is this because of the differences I outlined above?
In previous versions, there wasn’t a “ Add Store Code to Urls”. Now there is though, which can eliminate the need to have different stores in different directories. The option can be turned on/off under configuration->general->web
In previous versions, there wasn’t a “ Add Store Code to Urls”. Now there is though, which can eliminate the need to have different stores in different directories. The option can be turned on/off under configuration->general->web
Wow. Checking that box just saved me hours of work. Incredibly easy. Thanks so much!