photo credit: /facepalm via photopin (license)

The difference between a MAGE_RUN_TYPE website and store in Magento

So the other day I spent almost a day wrapping my head around a problem I ran into when I was trying to deploy a multistore- Magento site. The problem was that whatever I tried, the site kept showing the default Magento 404-page (not the sites’ one). I tried everything:

  • Flushing all caches (local, memcache, APC, etc).
  • Reindexing everything.
  • Making sure all store views were active and that they had the proper URL in the system configuration.
  • Checking my .htaccess  file to see if it provided the right store code according to the URL that was accessed.

I was really pulling my hair out with this one. Until I tried switching setting the MAGE_RUN_TYPE -flag in my .htaccess -file from website  to store .
Problem solved.
So what’s going on here?

The difference between a MAGE_RUN_TYPE website and store

As Magento puts it themselves:

“The code (i.e. MAGE_RUN_CODE and MAGE_RUN_TYPE) checks two environmental variables and use them to start Magento with the right website/store which can be defined in Manage Stores section in Admin.”

So if we read this correctly: the value of MAGE_RUN_TYPE determines if MAGE_RUN_CODE should be considered the code of a website or a store. Now let’s look at Magento: a website has a code (the default websites’ code is “base”), and a store (what is actually a view, since a store can have multiple views) also has a code (the default websites’ view is “default” by default, unless you’ve changed this off course).
Now if you have a situation like I had, where you had a Magento installation with multiple websites and each multiple stores, you have different codes for both. For example, you might have the following website codes:

  • site1
  • site2
  • site3

And the following store codes (each representing a view in a specific site):

  • site1_en
  • site1_nl
  • site2_en
  • site2_nl
  • site3_en
  • site3_nl

Now let’s see what happens when I try to do this:

What you telling Magento here is to load the website with the code site2_nl . But as we see, there is no website with that code. Therefore Magento will fallback to it’s default site, or show a 404 page if it fails to do that.

In conclusion

I wrote this article because like I said, I was pulling the hairs out of my head over this one, and it’s such a simple thing to miss. This article is a reminder for myself, but I also hope that it helps other Magento developers who encounter a similar problem.

Visitors give this article an average rating of 4.1 out of 5.

How would you rate this article?

3 thoughts on “The difference between a MAGE_RUN_TYPE website and store in Magento”

  1. Dan says:

    Very helpful. Thanks!

  2. Janusz says:

    Very helpful. Thanks! Magento doc is irritating.

  3. Clara says:

    Very Thanks!

Leave a Reply