Forum Moderators: phranque
i can
http://example.com/?user=xx1 to
http://xx1.example.com
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING}!user=[^&]
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.example\.com
RewriteRule (.*) /$1?user=%2 [L]
[edited by: jdMorgan at 12:13 pm (utc) on Sep. 27, 2007]
[edit reason] example.com [/edit]
One way to do it using a single rule:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} !&?user=[^&]+
RewriteCond %{HTTP_HOST}<->%{QUERY_STRING} ^(www\.)?([^.]+)\.example\.com(:[0-9]{1,5})?<->([^&]+&)*action=([^&]+)
RewriteRule (.*) /%5/$1?user=%2 [L]
Notes:
The subpattern following the HTTP_HOST subpattern is intended to recognize an optional (and valid) port number which may be appended to the hostname.
The <-> character sequence is arbitrary; While I use it to imply concatenation, it really only serves as a 'boundary marker' between the two combined values that we are trying to match in the RewriteCond. You could replace this with any character or character string as long as it is unique and cannot appear in a valid hostname.
Jim