OUR BUSINESS is building mobile solutions for YOUR BUSINESS

The internet is going mobile. Give your business the edge - Whether you need to mobile enable your customers, suppliers or staff, we can design and build YOUR SOLUTION... Websites, iPhone and Android.

Configuring Apache2

Configuring Apache2 Virtual Host to force non-www URLS


This works in Ubuntu 10.0.4 Intrepid... It's what I'm using.. not sure about other Linux distros... or other versions of Ubuntu.

These instructions assume you are using virtual hosts... so substitute your real domain name for yourdomain.com

You just need to edit your virtual host configuration for the site:

From the command line: sudo /etc/apache2/sites-available/yourdomain.com

You will see something like this :


Sorry, the email address had to be disguised to hide it from our own email hider :). We have a plugin that automatically check our articles for email addresses and hides them to cut down on spam. It needs to be a real email address, so change the "admin at yourdomainname DOT com" to a real email address.

Just add the following :

And you will end up with something like this :


That's it... now all of your requests with a www in the URL will be redirected to the same page without a www in the URL... As I said you can change the added part to force the "www"... but please don't... I hate typing it.. and I really hate having to say "www" all the time :).

Please register or login to post comments