.htaccess rewrite subdomains

Posted by Cyclone on Stack Overflow See other posts from Stack Overflow or by Cyclone
Published on 2010-04-05T16:32:43Z Indexed on 2010/04/05 23:23 UTC
Read the original article Hit count: 267

Filed under:
|
|

Here is my current code:

RewriteCond %{HTTP_HOST} !^example\.com [NC] 
#RewriteCond %{REQUEST_URI}!^something
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com 
RewriteRule (.*) something/%1/$1 [QSA,L]

My goal is to rewrite http://*.example.com/whatever to http://example.com/something/*/whatever, assuming * is the same for both and whatever is the same for both. However, I believe this is causing an infinite loop somehow, so I added that commented out line (RewriteBase is / btw), but if I uncomment then the entire site is a 500 response code. Without that line, only the subdomains error.

What am I doing wrong, and how can I fix this? I have already configured the server so anything gets redirected to my public_html folder.

EDIT: For clarification, I am trying to do an internal redirect, not external.

EDIT: There is not a flag for internal redirect it seems. Is there any place I can see the actual error message for the broken rewriterule? If I knew what was wrong I would be able to stand a better chance of fixing it.

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about mod-rewrite