redirecting to multiple virtual subdomains using htaccess
- by Gerald Ferreira
Hi Everyone
I am trying to create subdomains via htaccess. The code below does exactly want I want
It takes http://domain.com and redirect it to http://www.domain.com
Options -Indexes
DirectoryIndex index.html index.htm index.asp index.php
ErrorDocument 401 http://www.domain.com
ErrorDocument 403 http://www.domain.com
ErrorDocument 404 http://www.domain.com
ErrorDocument 500 http://www.domain.com
ErrorDocument 507 http://www.domain.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301]
AddType text/html .html .htm .asp
This is the part I am not to sure of:
RewriteCond %{HTTP_HOST} ^domain.com/nl$
RewriteRule ^(.*) http://nl.domain.com/$1 [QSA,L,R=301]
How can I create virtual subdomains so that if someone goes to http://nl.domain.com it would stay on http://nl.domain.com if someone types http://www.nl.domain.com it would take out the http://www.nl.domain.com and make it http://nl.domain.com also the directory structure for the subdomain would be http://www.domain.com/nl (This is where the actual files will be sitting).
so if someone goes to http://www.domain.com/nl it should also redirect to http://nl.domain.com.
Thanks in advance for any advice and pointers