Subdomain not pointing to script correctly

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

#Making domain.com/FILE.html work
RewriteRule ^([^.]+)\.html$ cgi-bin/site.cgi?channel=$2&page=$1 [L]

#Making the WHATEVER.domain.com part work.
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.domain\.info
RewriteRule ^([^.]+)$ cgi-bin/site.cgi?channel=$1 [L]

http-//CHANNEL.domain.info/PAGE.html

The page name points to the script correctly, but the

CHANNEL.domain.com

part of the URL does get the script, but it isn’t pointing to

cgi-bin/site.cgi?channel=CHANNEL

correctly. The channel info works fine at the original URL, but not the sub-domain URL.

Nin,

Comments on your code:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

#Making domain.com/FILE.html work
RewriteRule ^([^.]+)\\.html$ cgi-bin/site.cgi?channel=$2&page=$1 [L]

#Making the WHATEVER.domain.com part work.
RewriteCond %{HTTP_HOST} ^(www\\.)?([^.]+)\\.domain\\.info
RewriteRule ^([^.]+)$ cgi-bin/site.cgi?channel=$1 [L]
  1. The Options should be (and probably are) set in the server config file.

  2. RewriteBase is designed to UNDO a mod_alias Redirect. Where is that (or eliminate this directive)?

  3. Where did you get $2 from in the first RewriteRule? It’s either NULL or does not exist!

  4. Why do you have the RewriteCond statement in the second RewriteRule? It appears to be doing NOTHING.

If you’ll start with a specification (what you are trying to do), it would make it easier for us to support (other than commenting on code while not understanding what it’s supposed to do).

Regards,

DK

http-//CHANNEL.domain.info/PAGE.html

The page name points to the script correctly, but the

CHANNEL.domain.com

part of the URL does get the script, but it isn’t pointing to

cgi-bin/site.cgi?channel=CHANNEL

correctly. The channel info works fine at the original URL, but not the sub-domain URL.[/QUOTE]

Now I got it.
[noparse]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^.]+)\.html$ cgi-bin/site.cgi?page=$1 [L]
RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.com [NC]
RewriteRule (.*) cgi-bin/site.cgi?channel=%2 [NC,QSA]
[/noparse]
I was using the RewriteCond and last RewriteRule stuff to get the sub-domain part working. The sub-domain part wasn’t pointing correctly.

:tup:

Regards,

DK