Redirect www to non-www with a 301

/ Published in: Apache
Save to your folder(s)

I like using HTTP_HOST with a simple regex so it'll work in multiple environments, ie stage, production, dev, etc.

Copy this code and paste it in your HTML
  1. RewriteEngine on
  2. RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  3. RewriteRule ^(.*)$ http://%1/$1 [L,R=301]

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.