Page 1 of 1

mod_rewrite problem

Posted: Tue Apr 18, 2006 12:10 pm
by evilmonkey
A while ago, someone on these forums (don't remeber who) was nice enough to help me with the following mod_rewrite rule. Basically, when <something>.tmeet.com is entered, I want it to forward to tmeet.com/fwd.php?username=something. The obvious exception is www, which should point to the index page. However, I recently came up on a problem: tmeet.com (with nothing in front of it) gives me a 404 page.I posted my .htaccess file below, hoping one of you gurus can provide a pointer or two. :) Thanks.

Code: Select all

RewriteEngine on
RewriteCond   %{HTTP_HOST}        !^www\.
RewriteRule   ^(.+)               %{HTTP_HOST}          [C]
RewriteRule   ([^.]+)\.tmeet\.com$ fwd.php?username=$1

Posted: Tue Apr 18, 2006 1:32 pm
by asgerhallas
Hmm... I have not tested it, but something like this maybe:

Code: Select all

RewriteEngine on 
RewriteCond   %{HTTP_HOST}        !^www\. 
RewriteCond   %{HTTP_HOST}        !^tmeet\.com
RewriteRule   ^(.+)               %{HTTP_HOST}          [C] 
RewriteRule   ([^.]+)\.tmeet\.com$ fwd.php?username=$1

EDIT:

If your host does not normally allow accessing by "tmeet.com" without subdomain preceeding this might be better:

Code: Select all

RewriteEngine on 
RewriteCond   %{HTTP_HOST} ^tmeet\.com
RewriteRule ^.*$ http://www.tmeet.com [R]

RewriteCond   %{HTTP_HOST}        !^www\. 
RewriteRule   ^(.+)               %{HTTP_HOST}          [C] 
RewriteRule   ([^.]+)\.tmeet\.com$ fwd.php?username=$1

Posted: Tue Apr 18, 2006 2:26 pm
by evilmonkey
asgerhallas wrote:Hmm... I have not tested it, but something like this maybe:

Code: Select all

RewriteEngine on 
RewriteCond   %{HTTP_HOST}        !^www\. 
RewriteCond   %{HTTP_HOST}        !^tmeet\.com
RewriteRule   ^(.+)               %{HTTP_HOST}          [C] 
RewriteRule   ([^.]+)\.tmeet\.com$ fwd.php?username=$1
That did it, thank you very much. :)