Google, Bing Search Engine Consider these are Separate Domains:
- xyz.com
- xyz.com/
- xyz.com/index.html
- xyz.com/index.htm
- www.xyz.com
- www.xyz.com/
- www.xyz.com/index.htm
- www.xyz.com/index.html
So you can face Duplicate Website Content issue. Below are code to take care of this issue and 301 permanent redirect all those above listed domains to one single domain.
.htaccess 301 Redirect Code With HTML Extensions:
1. 301 permanent redirect index.html(htm) to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.xyz.com/$1 [R=301,L]
2. 301 permanent redirect non-www (non-canonical) to www
RewriteCond %{HTTP_HOST} !^(www\.xyz\.com)?$
RewriteRule (.*) http://www.xyz.com/$1 [R=301,L]
X--------------------------X----------------------------------------X
You Can also Put above Two Codes together:
RewriteEngine On
# 301 permanent redirect index.html(htm) to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.xyz.com/$1 [R=301,L]
# 301 permanent redirect non-www (non-canonical) to www
RewriteCond %{HTTP_HOST} !^(www\.xyz\.com)?$
RewriteRule (.*) http://www.xyz.com/$1 [R=301,L]
X--------------------------X----------------------------------------X
.htaccess 301 Redirect Code With PHP Extensions:
RewriteEngine On
# 301 permanent Redirect index.php to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://www.xyz.com/$1 [R=301,L]
# 301 permanent Redirect non-www (non-canonical) to www
RewriteCond %{HTTP_HOST} !^(www\.xyz\.com)?$
RewriteRule (.*) http://www.xyz.com/$1 [R=301,L]
Universal Code: With HTML and PHP Extensions:
RewriteEngine On
# 301 permanent Redirect index.html(.htm and .php) to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?|php)\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(html?|php)$ http://www.xyz.com/$1 [R=301,L]
# 301 permanent Redirect non-www (non-canonical) to www
RewriteCond %{HTTP_HOST} !^(www\.xyz\.com)?$
RewriteRule (.*) http://www.xyz.com/$1 [R=301,L]