redirecting domain.com to www.domain.com.

So you have a web server and one/some domain names. You want to have all requests to domain.com to go to www.domain.com. most companies have this redirect in place (Apple is an example). I was stumped when I first set out to do this…so here is what I learned from our friends on the Apache mailing list.

ServerName www.domain.com
ServerAlias domain.com
Redirect permanent / http://www.domain.com/

ServerName www.domain.com
ServerAdmin [email protected]
DocumentRoot /Volumes/www/domain.com/documents


This set up in Apache will then redirect all domain.com requests to www.domain.com.
You cannot beat mailing lists’ support!
[tags]apache, vhosts, redirect[/tags]