Skip to content

Multiple stores at different paths rendering wrong store base_url #1630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mttjohnson opened this issue Aug 7, 2015 · 1 comment
Closed

Comments

@mttjohnson
Copy link

I setup a site for testing multi-store functionality and found that a lot of the header and footer urls and possibly others on a page are referencing a single store view's base_url rather than the store view that is currently running.

My configuration

In the Magento Admin I am using the default website with a code of base.
I have setup the default store as Odin and have a single store view under that store with the code of default.
I setup a second store Thor with a single store view with the code of thor.

I then went into the Store -> Configuration -> General -> Web -> Base URLs and adjusted the Base URL values for each store view.
default = 'http://www.mage2base.dev/odin/'
thor = 'http://www.mage2base.dev/thor/'

I also setup symbolic links off the magento directory for /odin/ and /thor/
ln -s ./ thor
ln -s ./ odin

I also added entries to my .htaccess file:

############################################
## Multi-site configuration
##
    ## Sets an env var on secure page loads for www redirects ##
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ - [E=SECURE:s]

    RewriteCond %{REQUEST_URI} !^/(odin|thor|admin|index\.php) [NC]
    RewriteRule ^(.*)$ http%{ENV:SECURE}://%{HTTP_HOST}/odin/$1 [R=301,L]

    RewriteCond %{REQUEST_URI} ^/odin [NC]
    RewriteRule ^(.*)$ - [E=MAGE_RUN_CODE:default,E=MAGE_RUN_TYPE:store]

    RewriteCond %{REQUEST_URI} ^/thor [NC]
    RewriteRule ^(.*)$ - [E=MAGE_RUN_CODE:thor,E=MAGE_RUN_TYPE:store]

I had disabled caching for testing purposes and was running from a code base from August 3rd commit 83132783e0a6bed32c45e6d06df851865e668abc

Results I'm seeing

If I request the domain root http://www.mage2base.dev/ it redirects to http://www.mage2base.dev/odin/ as expected since that is the default store. At the bottom of the page the store switcher is displayed and has Odin listed, but the links in the header for My Account, My Wish List, Create an Account, and Sign In all have urls that use the base_url from the thor store view. The link for the cart also uses the wrong base_url, but the Advanced Search link has the correct base_url.
http://www.mage2base.dev/thor/customer/account/
http://www.mage2base.dev/thor/checkout/cart/
http://www.mage2base.dev/odin/catalogsearch/advanced/
http://www.mage2base.dev/thor/contact/

The Odin store displays the correct root category for the store and the correct URLs for category pages, so that part appears to work correctly.
http://www.mage2base.dev/odin/wisdom.html

I did notice on category pages where it listed products if I tried to change the Sort By option it would end up redirecting to a page that used the base_url of the thor store view http://www.mage2base.dev/thor/wisdom.html and end up on a 404 error page because that category didn't exist on the Thor store, so this base_url issue appears to be affecting a lot of things.

I have attempted setting up a third store loki and saw similar results with URLs using the base_url from the thor store view. I suspected that thor is likely getting picked as the last store view code in some sorted array. I tested this theory by creating another store view with a code of zend and then it was getting used as the base_url (http://www.mage2base.dev/zend/customer/account/) for the other stores instead of thor.

I tested changing the thor store view base url to something invalid like http://www.mage2base.dev/asdf/ and saw the header and footer links use that base_url in the links (Example: http://www.mage2base.dev/asdf/customer/account/) when accessing the Odin store at http://www.mage2base.dev/odin/

@mttjohnson
Copy link
Author

It looks like this has been fixed in the develop branch.

okorshenko pushed a commit that referenced this issue Oct 27, 2017
#11765 Allows modules with underscores in name to add blocks to layout via XML by @bentideswell
#11745 [Backport 2.2-develop] Fix label to avoid wrapping poorly,now break by word by @enriquei4
#11749 [Backport 2.2-develop] Fix datetime type product that show current date when is empty in grids by @enriquei4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants