0

We have an international store and the option to include the store view URL, i.e. URLs like

When the user opens, http://www.example.com/ we want to show an entry page with links to the different countries.

How to accomplish that?

My current approaches:

  1. Create an additional store view "landing", edit the CMS page "home" (I think I would need some tweaks to show this store view under the / URL)

  2. Or set the setting web/default/cms_home_page globally to a CMS page, lets say "landingpage". Overwrite it in the real stores.

  3. ???

Edit - additional: In our case we also use the "default" site as a template (for CMS pages) which we copy to the different countries - so this site is kind of impossible to use in production.

Edit - see @kalenjordan commeting on my Answer

3

This is how I'd do it:

  • Base url example.com (root, no language selected) would be the 'default' site as installed by Magento, i.e. the one with the store code 'default'.
  • The homepage for default is your 'select a store' gateway CMS page
  • That links to the subdirectories, which are physical directories in the webroot that have symlinked media, skin, js directories; index.php is a separate file that references ../app/Mage.php instead of app/Mage.php
  • The htaccess in subdirectories will define the store and run codes

Ideally your default site's root catalog is empty. The CMS homepage's custom layout xml could remove things like nav, header, footer. You could also have some customization in index.php to check for a store cookie so as to push them to their preferred site on future visits instead of requiring them to step through the language/locale gateway.

  • I've taken this approach before and I approve. +1. – Marius Sep 10 '13 at 20:08
  • Hm - I would prefer a simpler solution - already happy I do not need subdirectories by using Magento's "include store code in URL" feature. – Alex Sep 11 '13 at 8:48
  • I've never used that feature - definitely intrigued now. – philwinkle Sep 11 '13 at 14:39
  • 1
    Alias directive in vhost config: Alias /en "/path/to/vhost/root should work for Apache, and I've just yesterday seen similar technique in nginx config. – benmarks Sep 18 '13 at 10:25
  • You can also set MAGE_RUN_CODE and/or MAGE_RUN_TYPE in .htaccess with SetEnvIf instead of having physical directories and index.php and .htaccess copy/paste. – Dmytro Zavalkin Sep 18 '13 at 23:40
2

I would go with 1st approach. In a meanwhile you may want to add more pages irrelevant to any of localised store views or make some other customisations. This approach will give you a bit more flexibility.

  • +1 for future flexibility. Is there a non-hacky way to direct example.com to this example.com/landing. – Alex Sep 11 '13 at 9:41
  • self-answer: I think changing MAGE_RUN_CODE is easy and can be done in the .htaccess – Alex Sep 11 '13 at 10:03
2

A third option would be to rewrite the url http://www.example.com to the homepages or a different CMS page on any of the stores. So http://www.example.com would be rewritten to http://www.example.com/us/landing.html.

I've never tried it before but it should basically work. Magento would pick up on the full URL and process it as a normal CMS page

1

That is my final solution based on the community answers:

  1. Create global_website and store code: global
  2. Create CMS page home in Global Website
  3. Change MAGE_RUN_CODE env variable in vhost or .htaccess. Alternative in index.php, change default store code to global ($mageRunCode = 'global')
  4. Add Layout updates for the handle STORE_global to remove unneeded parts of the layout (for example the main menu)

Disclaimer:

Changing the index.php can lead to complications, you have to be careful during updates to merge your changes properly.

  • why not use a virtual host configuration instead of changing index.php? – user487772 Sep 11 '13 at 11:04
  • @Tim: I have a reason for that :-) But in general I suggest vhost or .htaccess. edited – Alex Sep 11 '13 at 14:02
  • In regard to the store codes. Shouldn't we be using full locale codes and not just language codes. For example, de-de, ca-en, ca-fr. Looks like Magento doesn't allow dashes in the store code, but only underscores. – kalenjordan Sep 17 '13 at 23:00
  • Hm - yes. I see, this questions is a bit broader :-) Feel free to add an edit to the question. – Alex Sep 18 '13 at 3:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.