Apache .htaccess -how to 301 redirect from a non-WWW to WWW.mysite.com

© 2022 www.JaxBeachTech.com  |  Ph: 9o4.834.o433  |   email  |  [50.41]

Submitted by donmc on Mon, 08/06/2012 - 12:08

I have had to mess with this way too many times, so just for the record, here is what works for me:
[this based on an Apache/2.2.14 (Ubuntu) system...]

  RewriteEngine on
  # this is for sites using port 80:
  RewriteCond %{HTTP_HOST} ^mysite.com [NC]
  RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]