0

I have to store view under a store whose code as default and crescent

when I run the domain name it should be pointing to default store and when I run URL as http://hostname/crescent it should pointing to crescent store

for example

http://localhost:81/ecommerce/ Should point to http://localhost:81/ecommerce/?___store=default

http://localhost:81/ecommerce/crescent Should point to http://localhost:81/ecommerce/?___store=crescent

To achieve this, I tried below

Under URL rewrite management I created a custom rule as below

Request Path: /

Target Path: ?___store=default

Redirect: Permanent

But no luck,

can someone suggest me on this.

1 Answer 1

2

You can do this either through server configuration (nginx/Apache) or through setting a $_SERVER['MAGE_RUN_CODE'] in index.php.

The latter would require creating a directory crescent in MAGENTO_ROOT, copying index.php to it and assigning a proper store code to be run there - in your case it would be crescent.

I'm assuming your MAGENTO_ROOT is inside /ecommerce/ directory (where your main index.php is placed).

Example of directory structure and index.php/.htaccess:

-- ecommerce
    |-- crescent
        | -- index.php (described below)
        | -- .htaccess (described below)
    |-- index.php

The content of index.php inside crescent would look something like this:

$_SERVER['MAGE_RUN_CODE'] = 'crescent';
$_SERVER['MAGE_RUN_TYPE'] = 'store';

URL Rewrites are used to rewrite entirely different things.

This solution with a separate directory also allows you to make a translation/separate design for error pages.

You could also use .htaccess for this where based on the URL you could do something similar to this which's based on domains:

SetEnvIf Host .*.pl* MAGE_RUN_CODE=crescent
SetEnvIf Host .*.pl* MAGE_RUN_TYPE=store

but you're sure that the store in /crescent/ should be that one so you can do this:

SetEnv MAGE_RUN_CODE=crescent
SetEnv MAGE_RUN_TYPE=store
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.