Apache – Redirect from non www to www

If you are hosting a site, and you already setup your domain with and without www, but still having issues when accessing without www. A great way to solve it, is using the following configuration on your virtual host.

If you are using SSL and https, you can use the following configuration: