Log in

View Full Version : .htaccess rewriting



Toms2056
03-09-2009, 09:43 PM
Hi, I haven't really used htaccess rewrite before but I've been told it can do what I want.
I'm currently using something which rewrites domain.com/xyz to domain.com/file.php?var=xyz
however, what I wish to do is redirect xyz.domain.com to this instead, how would I do this?

Thanks.

techietim
03-09-2009, 10:25 PM
RewriteEngine on
RewriteCond %{REQUEST_URI} =/
RewriteRule .* http://example.com/ [R,L]
RewriteRule (.+) http://$1.example.com/ [R]

If you go to example.org it redirects you to example.com
If you go to example.org/hello it redirects you to hello.example.com

Toms2056
03-10-2009, 04:17 PM
Hi, this is backwards to what I'd like to do;

I'd like to redirect xyz.example.com to example.com/page.php?var=xyz

If its just a simple rearrangement of that then I apologise, I don't know how to do it.
Thank you.