Magento – Multi store magento redirects to main store

magento-1.7multistoreredirect

I need to create create another store, I am following the instructions on the Wiki magento but I can not work.

my problem is that when you enter the second store redirects me to the main store

eg. subdomain.mydomain.com
when I enter redirects me to mydomain.com

I also tried to create folder using just the second store, the url is displayed like mydomain.com/store2

but it shows me the home page of my main store

Files:

index.php

Last lines

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'knksvip';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'website';

Mage::run($mageRunCode, $mageRunType);

.htaccess

RewriteCond %{HTTP_HOST} ^(.*)subdomain.mydomain.com
RewriteRule ^ - [E=MAGE_RUN_CODE:knksvip]

in store view Base URL Changed to

http://subdomain.mydomain.com/

Best Answer

I have no clue how the mod_rewrite settings is working, but for us always worked:

SetEnvIf Host www\.domain2\.com MAGE_RUN_CODE=storecode1
SetEnvIf Host www\.domain\.com MAGE_RUN_CODE=storecode2