www redirect

hallo, how do I have to set virtual server to have my website reachable as http://domain.com and, if someone use http://www.domain.com it is automatically redirected to http://domain.com? thank you



Howdy -- your website should already be reachable by domain.com and www.domain.com, that is setup for you automatically when you setup a Virtual Server.

Normally, what will happen is that both will simply show the same website.

If you really want www to redirect to the non-www, there's a few ways to do that... one of which would be to add a .htaccess file into your public_html dir, with the following contents:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

If you get an error of some sort after putting in that .htaccess, look at $HOME/logs/error_log for any errors that may give a clue as to problem.

I'm happy to help you get this working, but remember for future reference that the support tracker here is for Virtualmin Pro customers. If you're using Virtualmin GPL, you should pop your questions into the forums... thanks!