View Full Version : Subdomain Redirect WWW

09-11-2010, 02:07 AM
I'm trying to set up a subdomain to redirect to a directory. I'm also trying to make it so that it will redirect www. I have this:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTP_HOST} subdomain.domain.com
RewriteRule ^(.*)$ directory/$1 [L]

but it's not working. It get a 500 Internal Server error for subdomain.domain.com and www.subdomain.domain.com is not found. Any help is appreciated.


09-11-2010, 02:53 AM
Update: I messed around with it, and now, no matter what, subdomain.domain.com becomes an infinite redirect. I have no idea what's going on.

09-11-2010, 04:24 AM
If I understand you correctly, you want something like code.google.com to redirect to google.com/code?

RewriteBase /

RewriteCond %{HTTP_HOST} ^code.google.com [nc]

RewriteRule ^(.*)$ http://www.google.com/code/$1 [r=301,nc]

I THINK that should work.