Redirect example.com to www.example.com VPS & Apache2

Posted by Thomas Buckley on Server Fault See other posts from Server Fault or by Thomas Buckley
Published on 2011-06-23T23:59:54Z Indexed on 2011/06/24 0:24 UTC
Read the original article Hit count: 583

Filed under:
|
|
|

I have a VPS and a domain name registered with the provider.

When I enter www.example.com my site is displayed correctly, but entering example.com does not work. I am able to ping www.example.com.

I added the following line to my apache2 default vhosts file:

ServerName example.com
ServerAlias www.example.com

But this did not work.

The VPS is a Debian5 OS.

Any ideas? Note: There is no option via a provided control panel to add this, it's a basic package I purchased

I know this post answers it but there are no extra comments and I'd like to know if it's the best way:
way to redirect page to www using virtual host configuration in sites-available for apache2?

Thanks

© Server Fault or respective owner

Related posts about debian

Related posts about domain