Forum Moderators: phranque
I am a complete newbie to regular expressions and mod_rewrite and am faced with a specific need that I cannot figure out.
When a user visits:
[USERNAME.example.com...]
I need it instead to go to:
http://www.example.com/page.php?username=USERNAME
I cannot figure out how to get this right in htaccess using mod_rewrite
Any help would be GREATLY appreciated - thank you!
[edited by: jdMorgan at 11:20 pm (utc) on Sep. 14, 2007]
[edit reason] example.com [/edit]
apologies for not posting my incorrect code.
I know little to nothing about regular expressions, but here's the code (not working) I have currently:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST}!www.example.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).example.com [NC]
RewriteRule (.*) %2/page.php?username=$1 [L]
so...
the idea here is that someone coming to [USERNAME.example.com...] will land instead at http://www.example.com/page.php?username=USERNAME
Hope this helps
Options +FollowSymLinks +Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !www\.example\.com [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.example\.com [NC]
RewriteCond $1 !page\.php$
RewriteRule (.*) /%2/page.php?username=$1 [L]
Jim