mod_rewrite question

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

mod_rewrite question

Post by evilmonkey »

Hello,

I'm trying to set up mod rewrite so it will convert xxx.site.com to site.com/fwd.php?username=xxx. I got this in my htaccess:

Code: Select all

RewriteEngine on
RewriteRule ^([^/\.]+).site.com/? fwd.php?username=$1 [L]
But it doesn't seem to be working. Probably some dumb regex problem again. :( Any help is appreciated.

Thanks. :)
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

*bu-bu-bu-bump*
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Where is $1 coming from?
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Code: Select all

RewriteEngine on

RewriteCond   %{HTTP_HOST}        !^www\.
RewriteRule   ^(.+)               %{HTTP_HOST}          [C]
RewriteRule   ([^.]+)\.site\.com  /fwd.php?username=$1
Requires a wildcard ServerAlias definition in order to work.
Post Reply