Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Subdomain - variable Mod Rewrite doesnt work. Please help


jdMorgan - 3:30 pm on Nov 3, 2005 (gmt 0)


The problem may be that you are creating an external redirect, when I suspect you want an internal rewrite.

So, this might work better:

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]
# RewriteRule ^([^.]+).domain.com(.*) /home/httpd/vhosts/domain.com/httpdocs/$2 [L]

I don't know why you were using a proxy throughput, the RewriteMap was defined, but never invoked (now commented-out), and I can't fathom the purpose of your last rule (also now cemmented-out) at all.

I assume that the first RewriteCond was just copied and pasted from an existing code example. The usual intent of this type of construct is to prevent an 'infinite' rewrite loop if the request has already been rewritten to the "page" in the final rewriterule. So I have changed the first RewriteCond from testing for "/index.php" to "/viewforum.php" to prevent such a loop.

In addition, the user-requested "page name" will be discarded (subject to your exclusions), and all requests except for "/viewforum.php" or the pages in the "www" or "webmail" subdomains will be rewritten to "/viewforum.php". I hope that's what you want, but I don't know.

It is possible that your sessions cookie is domain-based. Because you were doing a redirect or proxy throughput, that domain was changing, so the session no longer applied. If the above does not "work better", then you'll need to dig into the logic underlying session tracking to find out what dependencies apply to sessions.

Replace all broken pipe "¦" characters above with solid pipes before use; Posting on this forum modifies them. Flush your browser cache after any change to the code.

Jim


Thread source:: http://www.webmasterworld.com/apache/4866.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com