I am trying to achieve virtual subdomain as my hosting provider has set a limitation on the number of subdomains I can have! I already have a wildcard DNS entry so all subdomains are accepted and send to the root of my domain. Here's what I have put in .htaccess to handle the redirection:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www|admin).* [NC]
RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9]+)\.domain\.-com
RewriteCond /home/username/public_html/subdomain/%1 -d
RewriteRule ^(.*) /home/username/public_html/subdomain/%1/$1
The problem is in the last line which does the actual redirection, the server shows a 500 (Internal server error), but the apache error log does not expand the error. In its place if I put something like:
RewriteRule ^(.*) index.php?path=/home/username/public_html/subdomain/%1/$1
It works fine... And the path is the correct file path.
RewriteEngine on # first prevent recursion RewriteCond %{ENV:REDIRECT_STATUS} ^$ # second handle subdomains RewriteCond %{HTTP_HOST} !^(www|admin)\.* [NC] RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9]+)\.domain\.com RewriteCond /home/username/public_html/subdomain/%1 -d RewriteRule (.*) /subdomain/%1/$1 [L]