Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule ^/(.*)$ http://%1/$1 <-- don't want a redirect, just let apache use the new vhost The reason I want this is because I've got ~ 10,000 vhosts set up with vhost_alias. Each vhost is a symlink to the user's homedir, ie
/var/www/vhosts/example.com --> /var/wwwroot/user0001
/var/www/vhosts/www.example.com --> /var/wwwroot/user0001 I could use half the number of symlinks if I could just get rid of the www symlink. :)
Thanks,
Martin
No, the hostname can only be changed by using a redirect.
If (as in your code example) you include "http://x.y.z/" in the RewriteRule substitution, and do not specify [R=nnn] in the RewriteRule flag, then Apache will generate a 302-Moved Temporarily redirect response by default.
You might consider using an alternate form of the VirtualDocumentRoot directive rather than the default (%0) form. For example:
UseCanonicalName Off
VirtualDocumentRoot /usr/local/apache/vhosts/%0.-2.%0.-1
See Apache mod_vhost_alias [httpd.apache.org] for more information.
Jim
I assume what you meant was
VirtualDocumentRoot /usr/local/apache/vhosts/%-2.0.%-1.0 I guess what I really need then is something like
if (host begins with "www.")
{
VirtualDocumentRoot /usr/local/apache/vhosts/%1+
}
else
{
VirtualDocumentRoot /usr/local/apache/vhosts/%0
} Is this possible?