Home > Magento Tips > Change Store View by Referer URL

Change Store View by Referer URL

Posted on: 24th Jan 2012 By: Robert Kent 1 Comment

Did you know that you can load a store view depending on the website referer you came from?

For example if I wanted to load my UK store view on mywebsitesshop.com because my customer visited from mywebsite.co.uk I could do this easily by adding a little piece of htaccess code.

What you’ll need is this:


SetEnvIf Referer mywebsite.co MAGE_RUN_CODE=myuksitecode
SetEnvIf Referer mywebsite.co MAGE_RUN_TYPE=store

Put that at the top of your htaccess file and make sure that “myuksitecode” matches up with the identifier you have for your store view.

Thanks for visiting the Magento Blog here at Ecommerce Web Design.

One Response to “ Change Store View by Referer URL ”

  1. Viktor Zhuromskyy
    #1 | 12th February 2012

    Thank you for the tip, but it will not work like this.
    Proper code will be

    SetEnvIf Referer www\.mywebsite\.co MAGE_RUN_CODE=myuksitecode
    SetEnvIf Referer www\.mywebsite\.co MAGE_RUN_TYPE=store
    SetEnvIf Referer ^mywebsite\.co MAGE_RUN_CODE=myuksitecode
    SetEnvIf Referer ^mywebsite\.co MAGE_RUN_TYPE=store

Post A Comment

Your comments:
Enclose code snippets within the appropriate tags: [php][/php]   [js][/js]   [xml][/xml]   [css][/css]   [html][/html]
E.g: [php]<?php echo "hello world"; ?>[/php]

Search Blog

Archives

For the record...

Views & opinions in this blog are those of the individual and do not necessarily reflect those of E-commerce Web Design or the Creare Group.