Posted By

jfine on 11/03/10


Versions (?)

Redirect non-www to www with a 301

 / Published in: Apache

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

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

Report this snippet  

You need to login to post a comment.