So I'm attempting to setup a second website under Magento, and I'd like it to be on a subdomain, for example, second.mywebsite.com
. My main store is mywebsite.com
. I've essentially got everything setup on Magento itself, and have the subdomain created.
First, using cPanel, creating a new subdomain automatically points it to /public_html/second
and wasn't sure if that's correct since I know it needs to point my root directory.
Second, I'm unsure of the correct configuration for .htaccess
to get correct redirecting. I already have one redirect setup for a test environment, located at dev.mywebsite.com
. What I have for rewriting currently:
RewriteCond %{HTTP_HOST} !^dev\.mywebsite\.com/$
RewriteRule .* index.php [L]
I know this isn't entirely correct, because right now everything else doesn't redirect correctly back to index.php
. For instance, abcd.mywebsite.com gives a "SORRY!" cPanel page.
What I think I need to add:
RewriteCond %{HTTP_HOST} www\.mywebsite\.com [NC]
RewriteRule .* - [E=MAGE_RUN_CODE:site_code1]
RewriteCond %{HTTP_HOST} www\.mywebsite\.com [NC]
RewriteRule .* - [E=MAGE_RUN_TYPE:website]
RewriteCond %{HTTP_HOST} !^second\.mywebsite\.com [NC]
RewriteRule .* - [E=MAGE_RUN_CODE:site_code2]
RewriteCond %{HTTP_HOST} !^second\.mywebsite\.com [NC]
RewriteRule .* - [E=MAGE_RUN_TYPE:website]
Am I headed in the right direction? I basically need to get the two above to redirect properly to the correct website stores, the dev subdomain to redirect correctly and then anything else to the main website.
I have tried above and have no luck on correct redirect.
I've set up the subdomain as shown below, with its document root pointing to the same root of the main site:
Update: I've managed to correctly setup the subdomain as an alias of the the main site. All I'm having trouble with now is getting the site to actually show the correct website/store when using the subdomain. So essentially, the correct syntax for the .htaccess
file. Also whether I'm using the Website's code or the Store View's code in that block of code.