logo   Downloads About Contact

Routing www to non-www in .htaccess

It is unsual to write www. in front of an host anymore. Depending on your scripts, this could be a source of failures as many hosting providers automatically support http(s)://host and http(s):// To avoid problems I route hosts directly to non-www adresses using an .htaccess file:

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