Wednesday, February 27, 2013

Non WWW to WWW redirection using htaccess File



Non WWW to WWW redirection  



This code using Htaccess, and also redirect index.html file to same directory in website. 

RewriteEngine on

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ http://www.websitename.com/$1 [R=301,L]

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


For Examples
1. http://websitename.com

using above code
http://www.websitename.com

2.  http://websitename.com/index.html or http://www.websitename.com/index.html


using above code
http://www.websitename.com/


No comments:

Post a Comment