Need some help setting up subdomains for my site
- by KarimSaNet
I'm setting up my website and want to have it so all subdomain requests are rewritten to the appropriate subdirectory. For example
http://projects.karimsa.net/ -> http://karimsa.net/projects/
But I want to use the Apache rewrite mod to do this so that the URL in the browser stays the same. Here is what my config looks like at the moment:
## rewrite subdomains
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*).karimsa.net
RewriteCond %{HTTP_HOST} !^www.karimsa.net [NC]
RewriteRule ^(.*)$ http://karimsa.net/%1/$1 [R=301,L]
And my CNAME records on 'projects.karimsa.net':
Domain TTL Data Type
projects.karimsa.net 14400 karimsa.net CNAME
Theoretically, I feel this should work. But when I go to the URL, it gives me a server misconfiguration error, my provider's default webpage. What I should see is the index.php under /projects/.
What am I doing wrong? Any help would be appreciated, thanks for reading.
Addition:
I realized I forgot to mention some of the problem. The domain 'karimsa.net' is parked at 'karimsa.x10.mx'. If I set up the same configuration on 'projects.karimsa.x10.mx', the rewrite and CNAME work. But on the parked domain I still get the default webpage.