I just bought the domain vas.im, I added a DNS rule for vas.im and www.vas.im, then I tried to get apache2 to redirect the latter to the former. I enabled mod_rewrite, appended /etc/apache2/httpd.conf
, which follows, and restarted the apache2 service.
ServerName localhost
AccessFileName .htaccess
# Redirect www to non-www
RewriteEngine On
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[url]www.vas.im[/url] [NC]
RewriteRule ^(.*)$ [vas.im...] [L,R=301]
I must have made some mistake, since the www domain does not redirect. I don't pretend that I understand mod_rewrite, so I'm wondering if someone here knows what the issue is.
I would suggest you to do this:
Alternatively, you can change the first virtual host block to: For this method you have to use
mod_alias's
Redirect
. So, make sure you have loaded themod_alias
module in your.conf
file.