Forum Moderators: phranque

Message Too Old, No Replies

.htaccess mod_rewrite:

how to redirect a search string

         

fenimor

3:34 pm on May 17, 2006 (gmt 0)

10+ Year Member



Hi,

Here what I would like to do: I need htaccess rules to redirect

www.example.com -> index.php
www.example.com/date/24h -> index.php?sort=date&time=24h
www.example.com/rank/24h -> index.php?sort=rank&time=24h

and then the same for subdomainds

sub1.example.com -> index.php?sub=sub1
sub1.example.com/date/24h -> index.php?sub=sub1&sort=date&time=24h
sub1.example.com/rank/24h -> index.php?sub=sub1&sort=rank&time=24h

and so on for sub2.example.com, sub3 .. sub 5

I know a bit about mod rewrite, but I don't know how to approach this problem without writing separate rewrite rules for each subdomain?

Thanks in advance...

jdMorgan

4:06 pm on May 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use a RewriteCond such as

RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com

to extract the subdomain and create a back-reference for use in the RewriteRule.

Jim