Forum Moderators: phranque

Message Too Old, No Replies

httpd.conf: 2 domains with virtual subdomains using Rewrite

         

ras_andy

11:01 pm on Aug 16, 2004 (gmt 0)



hi there,
members (on 2 or more vhosts) should access their data through http://username123.domain.com which are virtual subdomains.
the first domain listed in httpd.conf works fine understanding http://foo_1.example.net and http://foo_xyz.example.net (see code below)
but how to get a second domain to react in the same way on the same server? (code below)

<VirtualHost example.net:80>
ServerAdmin info@example.net
DocumentRoot /var/www/html
ServerName example.net
ErrorLog logs/example_error_log
CustomLog logs/example_log combined
RewriteEngine On
# Extract the member name from the host name
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.net$ [NC]
# The main domain (www) is not a member name
RewriteCond %1 !^www$ [NC]
RewriteRule ^.*$ http://example.net/usertemps.php?user=%1 [L]
</VirtualHost>


<VirtualHost quux_foo.org:80>
ServerAdmin info@quux_foo.org
DocumentRoot /var/www/quux_foo.org
ServerName quux_foo.org
ErrorLog logs/quux_foo_error_log
CustomLog logs/quux_foo_log combined
RewriteEngine On
# Extract the member name from the host name
RewriteCond %{HTTP_HOST} ^([^.]+)\.quux_foo\.org$ [NC]
# The main domain (www) is not a member name
RewriteCond %1 !^www$ [NC]
RewriteRule ^.*$ http://quux_foo.org/usertemps.php?user=%1 [L]
</VirtualHost>

maybe one has to play around with REQUEST_URI as a RewriteCond , but i have no idea ...
thanks in advance for any help
andy

[edited by: jdMorgan at 11:15 pm (utc) on Aug. 16, 2004]
[edit reason] Removed specifics per TOS [/edit]

jdMorgan

11:22 pm on Aug 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ras_andy,

Welcome to WebmasterWorld!

I can't say that this will fix it, but you should use canonical URLs as RewriteRule substitutions only when you are doing external redirects. Try using the form:


RewriteRule ^.*$ /usertemps.php?user=%1 [L]

Also, the HTTP_HOST patterns should not be end-anchored, in case the user, the user's browser, or a caching proxy appends a port number, i.e. www.example.com:80. This would be a valid request, but would cause the matches against your end-anchored patterns to fail.

Jim