apache config help needed

Discussion in 'Site & Server Administration' started by sergey2, Sep 20, 2006.

  1. #1
    Hi all!
    i need to setup a virtual host so that if someone hits http://mydomain.com he redirected to http://www.mydomain.com.

    i did this before on other machine with

        
    Servername www.mydomain.com
    ServerAlias mydomain.com
    
    Code (markup):
    in VirtualHost directive and


    
    RewriteEngine On
    ErrorDocument 404 /404.html
    
    # Non-canonical hosts? 301 please.
    RewriteCond %{HTTP_HOST}   !^www [NC]
    RewriteRule ^(.*)$         http://www.mydomain.com/$1 [R=301,L]
    
    Code (markup):
    in .htaccess

    I did this on my new server, but the redirect doesn't work. What can be the cause?
    Thank you.
     
    sergey2, Sep 20, 2006 IP