Blog

htaccess file to redirect non www. and redirect index.html

The following code is what I use in the .htaccess file to add the www. onto the domain and redirect /index.html to the domain.

RewriteEngine On
Options +FollowSymLinks

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

RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://%{HTTP_HOST}/$1 [R=301,L]

Leave a Reply

Your email address will not be published. Required fields are marked *