Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule

need some help guys

         

g3rmanoo

2:16 pm on Feb 8, 2007 (gmt 0)

10+ Year Member



i've this in htaccess:

Options All
RewriteEngine on

RewriteCond %{HTTP_HOST} !^(www\.)?domain.org [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain.org$ [NC]

RewriteRule ^([a-zA-Z0-9\_\-]+)\.html index.php?action=$1&user=%1 [QSA,L]

eg.

usertest.domain.org/view.html => domain.org/index.php?action=view&user=usertest

ok good but i need another one , this one:

usertest.domain.org/ => domain.org/index.php?user=usertest

can you help me?

so ONLY if i have html file after domain name or nothing after.

hope i was clear enough and sorry for my bad english. thanks!

jdMorgan

11:04 pm on Feb 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok good but i need another one , this one:

usertest.domain.org/ => domain.org/index.php?user=usertest

so ONLY if i have html file after domain name or nothing after.

I hope I have understood what you are asking. If you wish to add a rule to rewrite "xyz.example.org/" with "nothing after the domain name" to index.php with only the "user=xyz" parameter, then that would be something like this:


RewriteCond %{HTTP_HOST} !^www\.example\.org [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.org [NC]
RewriteRule ^$ index.php?user=%1 [NC,QSA,L]
#
RewriteCond %{HTTP_HOST} !^www\.example\.org [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.org [NC]
RewriteRule ^([a-z0-9_\-]+)\.html$ index.php?action=$1&user=%1 [NC,QSA,L]

I made several other changes to the code above to improve efficiency and correct a small bug.

Jim