[NTLUG:Discuss] Apache redirect....doesn't

Cameron Moore lists at unbeatenpath.net
Tue Mar 5 04:52:48 CST 2002


* ntlug at rain.lewisville.tx.us (Richard Geoffrion) [2002.03.05 02:33]:
> Can anyone point out what I may be doing incorrectly in trying to redirect
> URL1 to URL2?
> 
> Here is what I have in my web server configuration.  According to all of the
> documentation I've read, http://domainname.com SHOULD redirect to
> http://www.domainname.com.  What is currently happening is that ANY virtual
> web site that is addressed without the 'www.' prefix to the domain name is
> being sent to the default web site directory.
> 
> [snip]
> 
> <VirtualHost 192.168.0.1>
>     Redirect http://domainname.com http://www.domainname.com
>     ServerAdmin webmaster at domainname.com
>     DocumentRoot /home/domainname/public_html
>     ServerName www.domainname.com
>     ErrorLog /var/log/domainname-error_log
>     CustomLog /var/log/domainname-access_log common
> </VirtualHost>
> [/snip]
> 
> I've tried..
> 
> Redirect domainname.com http://www.domainname.com
> and
> Redirect  /   http://www.domainname.com
> 
> ...to no avail.
> 
> UG!  Any suggestions?

I'm not exactly sure what you're after, but here's what I do with all my
vhosts:

  <VirtualHost 206.142.128.250>
    ServerAdmin webmaster at unbeatenpath.net
    ServerName unbeatenpath.net
    ServerAlias www.unbeatenpath.net
    DocumentRoot /var/www/vhosts/unbeatenpath.net/html
    ErrorLog /var/www/vhosts/unbeatenpath.net/logs/error.log
    CustomLog /var/www/vhosts/unbeatenpath.net/logs/access.log common
  </VirtualHost>

Note the use of ServerAlias.  Is this what you're after?
-- 
Cameron Moore
/ I put tape on the mirrors in my house so I don't  \
\ accidentally walk through into another dimension. /




More information about the Discuss mailing list