Directory Index (Default Document) to Root Directory Redirect
Default document is request whenever a request arrives for your site’s or application’s root directory, the common default document being
- index.html
- index.php
- Index.htm
- Default.asp
- Default.htm
- Iisstart.htm
Any document other than mentioned above can be the default document ,in Apache you can change default Document with the below code.
### change default Document ###
###############################
DirectoryIndex index.html
# You can have any document
# Example index.txt ,/cgi-bin/index.pl and more
The same content will be displayed even if requested mentioning the default document, many people think that as same page but technically all of these pages are different. Search Engines take them as different page and it causes a duplicate content.
It is necessary that your home page lives at a single URL and do a 301 permanent move redirect to it to get high rank in search and avoid duplicate content. In this tutorial we will make a 301 redirect to Directory root from rest of possible URL’s, you can choose any URL as your home page.
Though many CMS like Word Press have solved it, still Drupal 7.15, Joomla 2.5.6 displayed the same home page for few URL when tested.I have submited the issue to the community hoping it get solved in next update or next release.
The following code will redirect YourSite.com/index.php
to YourSite.com
RewriteEngine On
### Redirects index to root ###
###############################
RewriteRule ^(.*)index.php$ http://techstream.org/$1 [R=301,L]
If you are adding this to the .htaccess file in Root directory this will take effect for the child directories also.
If you use a CMS then make sure that you don’t change the code for URL Rewrite or other functions used by CMS and also make sure you read CMS Documentation or wait for an update from them.