cancel
Showing results for 
Search instead for 
Did you mean: 

Multi Store Site 301 redirects product page to itself when switching store view

Multi Store Site 301 redirects product page to itself when switching store view

I have a multi site install, and today added a second view to one of the websites. All works as expected except.. When in view1 and switching to view2 the focus switches to the equivalent page in the target view i.e if i am looking at category 1 in view1 and switch to view 2 i get category 1 in view as expected. All pages work, home page CMS pages, add to cart etc except for product pages. The switch creates the right target URL  but the stores returns the url with a 301 and hence teh redirect loop. I've done all the usual, cleared caches etc but am stuck. Any ideas?

 

An example url is "https://animals.sugarshopper.com/set-of-2-metal-angels-blowing-horns?SID=8b8f13d75018d668c8b0c908c6b...

 

In this case looking at set of 2 angels product in store "sugar" then switching to store "animals" gets the 301 loop. Pasting the above url into a browser shows teh loop. Removing the two parameters from the url then paste works fine as expected. 

5 REPLIES 5

Re: Multi Store Site 301 redirects product page to itself when switching store view

The same is happening to me just on product pages too, somehow the store view switcher is not working properly on my product page and we're facing an infinite redirect loop too when switching the language (store view)  "..................?___store=default&___from_store=english"

 

Categories, pages or brands are working OK and get the content traslated but the product pages do not...Could it be related with the latest security patches?

 

Re: Multi Store Site 301 redirects product page to itself when switching store view

My stores are up today with patches to 1.9.2 except for 9767. I backed that patch out as it had a conflict with an extension and i've seen problems with it in another store i maintain. I am sure my htaccess is correct. The only redirect it performs is the non www to www redirect. I cleared all caches and truncated the url rewrite table and set the non secure url to http rather than https. All to no avail. 

Re: Multi Store Site 301 redirects product page to itself when switching store view

Copied below my update on a different ticket about similar issues. As said on the other opened ticket any ideas would be more than welcome.

 

UPDATE: I've replaced my .htaccess with a fresh one and the problem is still there Smiley Sad

--- Strangely, the store view switcher is working as it should with all the other pages adding the suffix (?___store=english&___from_store=default) but falls into an infinite loop with the product pages... The URL_KEY is set to Global and all store views share the same URL.

Re: Multi Store Site 301 redirects product page to itself when switching store view

Fixed! The problem with the storeview switcher just on product pages (infinite loop) was caused by the file languages.phtml located here: /app/design/frontend/default/<your_theme>/template/page/switch/languages.phtml; 

 

specifically with this line that was missing the "(false)" part: 

 

<option value="<?php echo $_lang->getCurrentUrl(false) ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>

Re: Multi Store Site 301 redirects product page to itself when switching store view

Baghulia's solution above works just fine but only if your product's URL keys are the same in all stores. If you're localising the URL keys, then adding false into getCurrentUrl() will take you to a 404 page. 

It seems that the issue comes from Magento escaping the ampersand in the URL. It will give you a query string that looks something like:

 

https://www.example.com/product_page.html?___store=german&amp;___from_store=english

 

My solution to this is to just str_replace the escaped ampersand like this:

 

<?php echo str_replace('&amp;', '&', $_lang->getCurrentUrl(); ?>

Kudos to Baghulia for setting me on the right track.