This is a discussion on mod_rewrite regular expressions within the Apache Web Server forums, part of the Web Server and Related Forums category; RewriteCond %{HTTP_HOST} ^([^\.w{3}]+)\.voosu\.com$ [NC] RewriteRule ^.*$ http://www.example.com/user.php?id=%1 [P,L] Here's ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
RewriteCond %{HTTP_HOST} ^([^\.w{3}]+)\.voosu\.com$ [NC]
RewriteRule ^.*$ http://www.example.com/user.php?id=%1 [P,L] Here's what I'm trying to do: anyusername.example.com --> www.example.com/user.php?id=anyusername Everything works fine, except one thing. Before I redirect I want it to check for any mention of "www" (so that there's no continuous loop) and maybe a few other terms in the subdomain (let's say "private" for the sake of discussion) that I don't want people to register as usernames. So this means www.example.com and private.example.com wouldn't get used in this RewriteRule. The problem is w{3} rejects a subdomain that has even just one "w" in it. This means no one on my site can have a "w" in their name, which is bad. What do I do to fix this? Second, I don't even know how to include "private" or any other term i want excluded into the regular expression. Can somebody help me? I've tried googling this and looking up the most obscure and complicated web sites but I can't find anything easy to understand. Thanks! |
|
|||
|
<Joe.Lavers@gmail.com> schreef in bericht
news:1169062179.825605.233800@a75g2000cwd.googlegr oups.com... > RewriteCond %{HTTP_HOST} ^([^\.w{3}]+)\.voosu\.com$ [NC] > RewriteRule ^.*$ http://www.example.com/user.php?id=%1 [P,L] IIRC a negated class -[^..]- takes all characters literal and thus makes the quantifier -{...}- useless. Some versions allow ^([^\.(w{3})]+)\.example\.com. Feel free to test this thought RewriteCond %{HTTP_HOST} !^(www|private)\.example\.com$ [NC] RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC] RewriteRule ^.*$ http://www.example.com/user.php?id=%1 [P,L] P ... do you realy want to proxy, consider remapping HansH |