Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite exception. Need a little help here.

mod_rewrite subdomain



4:24 pm on May 22, 2006 (gmt 0)

10+ Year Member

I created a script rewrite URL that creates fake subdomains from a query string parameter. For example:

[domain.com...] to [bandname.domain.com...]

The mod_rewrite script also exclude or prevent the [webmail.domain.com...] from being rewriten. Here is the script:

ServerAlias *.domain.com
RewriteEngine on
# RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_URI}!^/viewforum\.php$
RewriteCond %{HTTP_HOST}!^(www¦webmail)\.domain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
RewriteRule . /viewforum.php?f=%1 [L]

The script worked perfectly, but now I have a problem. I created another subdomain for my site (http://blogs.domain.com) but I dont know how to exclude it from the mod_rewrite script. I tried to modify it but it doesn't work. Here is the modified script

RewriteEngine on
#RewriteMap lowercase int:tolower
ServerAlias *.domain.com
RewriteCond %{REQUEST_URI}!^/viewband.php$
RewriteCond %{HTTP_HOST}!^(www¦webmail).domain.com
RewriteCond %{HTTP_HOST}!^(www¦blogs).domain.com ---> i added this script to exclude blogs.domain.com
RewriteCond %{HTTP_HOST} ^([^.]+).domain.com
RewriteRule . /viewforum.php?f=%1 [L]

It doesn't work as I expected. I can't access the subdomain site and when i browse it, it goes to the [domain.com...] homepage.

Please advise what to do. Please help.

Thank you very much


6:53 pm on May 22, 2006 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/viewforum\.php$
RewriteCond %{HTTP_HOST} !^(www¦webmail¦blogs)\.domain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
RewriteRule . /viewforum.php?f=%1 [L]

Replace all broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.



4:04 am on May 23, 2006 (gmt 0)

10+ Year Member

Thank you very much Jim.

Should I also remove or retain this line?

ServerAlias *.domain.com

Thanks for the help.


Featured Threads

Hot Threads This Week

Hot Threads This Month