Generic .htaccess redirect non-www to www (apache)

I remember to have this note somewhere, but always lose it for some random reason.

So here you go :

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

Source : Stack Overflow

Share

One thought on “Generic .htaccess redirect non-www to www (apache)”

Tinggalkan Balasan