General

How to redirect www to non-www with the .htaccess

I’ve seen this done many ways, but my go to script is simple and doesn’t require any customizations for each domain.

Here’s my quick and simple way to force www to non-www.

Add this to your .htaccess file


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

Shares