301 redirect non www to with www code / index.php code / index.html code - htaccess

301 redirect non www to with www code

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

301 redirect index.html and index.php to non index.html and index.php

index.php code

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

index.html code

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


EmoticonEmoticon

Info