0

I've spent more than a week to solve the problem with URL's in my Multiple Stores in Magento Community 2.3.2, but I got nothing.

What I need:

URL structure: example.com/store_name/store_viewname instead of typical example.com/store_viewname offered by Magento 2 with "Add Store Code to Urls" activated.

What I've done:

1) Created Website - Store - Store View.

2) Added individual Secured and Non-secured Base URL and Base Link URL for each store like: http://example.com/store_name/ and https://example.com/store_name/

3) Pointed proper CMS Home page in Default pages

4) Created subfolder with index.php and .htaccess with modifications:

require __DIR__ . '/app/bootstrap.php'; #tried /../app/ also
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'store_viewname'; 
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
$bootstrap->run($app);

and .htaccess below RewriteEngine = On:

SetEnvIf Host www\.example\.com/store_name MAGE_RUN_CODE=store_viewname
SetEnvIf Host www\.example\.com/store_name MAGE_RUN_TYPE=store
SetEnvIf Host ^example\.com/store_name MAGE_RUN_CODE=store_viewname
SetEnvIf Host ^megamolis\.ru/store_name MAGE_RUN_TYPE=store

RewriteCond %{REQUEST_URI} ^/store_name/.* [NC,OR]
RewriteCond %{REQUEST_URI} ^/store_name$ [NC]
RewriteRule .* - [E=MAGE_RUN_CODE:store_viewname]
RewriteCond %{ENV:REDIRECT_MAGE_RUN_CODE} (.+)
RewriteRule .* - [E=MAGE_RUN_CODE:%1,E=MAGE_RUN_TYPE:store]`

Of course, Cache Flashed and php bin/magento setup:static-content:deploy -f after changes. And symlinks of app, pub, lib, var added to the subfolder. Moreover, I tried to create subfolders both in example.com and example.com/pub for checking.

What I've got:

example.com/store_name

Whoops, our bad...
The page you requested was not found, and we have a fine guess why.
If you typed the URL directly, please make sure the spelling is correct.
If you clicked on a link to get here, the link is outdated.

It seems 404.

This error designed in the style of Magento. example.com/static and example.com/media work in design of DEFAULT store. Because I added the path (Base URLs) to example.com/static/ and example.com/media/ in Store Config.

example.com/store_name/store_viewname has the same result

And if I try to change the store to default it redirects to https://example.com/store_name/store_viewname/stores/store/redirect/ instead of example.com

example.com works perfectly. I need your help. Thank you.

Now, I want to add some information: I use Apache + NGINX

Store config in Magento Admin Panel:

Url Options

Auto-redirect to Base URL - Yes (302 Found)

Search Engine Optimization

Use Web Server Rewrites - Yes

Base URLs

Base URL - http://example.com/store_name/ Base Link URL - http://example.com/store_name/ Base URL for Static View Files - http://example.com/static/ Base URL for User Media Files - http://example.com/media/

Base URLs (Secure)

Secure Base URL - https:... the same above Secure Base Link URL - https:... the same above Secure Base URL for Static View Files - https:... the same above
Secure Base URL for User Media Files - https:... the same above Use Secure URLs on Storefront - Yes
Enable HTTP Strict Transport Security (HSTS) - No Upgrade Insecure Requests - Yes

Default Pages

Default Web URL - cms CMS Home Page - Store_name_page Default No-route URL - cms/noroute/index CMS No Route Page - 404 Not Found 1 CMS No Cookies Page - Enable Cookies Show Breadcrumbs for CMS Pages - Yes

Default Cookie Settings

Cookie Lifetime - 3600
Cookie Path -
Cookie Domain - Use HTTP Only - Yes

Browser Capabilities Detection

Redirect to CMS-page if Cookies are Disabled - Yes Show Notice if JavaScript is Disabled - Yes Show Notice if Local Storage is Disabled - No

0

You must accord your code based on https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_over.html

MAGE_RUN_TYPE can be either store or website
Use website to load a website in your storefront.
Use store to load any store view in your storefront.
MAGE_RUN_CODE is the unique website or store view code that corresponds to MAGE_RUN_TYPE

Can you post a screenshot of your stores configuration?

You can also read https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_apache.html

| improve this answer | |
  • As you see in my question, the "store" is applied everywhere in the code. – user86662 Mar 7 at 6:41

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.