Forum Moderators: Robert Charlton & goodroi
I need to make sure that the .htaccess does the following:
1) all non-www redirects to www
2) pages like /index.php get redirected to /index.php/ (as discussed here [webmasterworld.com...]
3) www.domain.com/index.php/ the always redirects to the root directory www.domain.com
I also need the robots.txt file to only disallow Google (and other engines) to index certain directories/pages of the site that could cause duplicate filters (resulting in the site being banished to the supplemental index).
www.domain.com/index.php/ the always redirects to the root directory www.domain.com
I had to do the direct opposite on my wordpress site to get the permalink situation working correctly. (www.domain.com to www.domain.com/index.php/)
Think this could cause problems? One bad fallout of this is I totally lost indexing on MSN about 6 months ago.
1) all non-www redirects to www
This can be accomplished in a variety of ways ( I implemented all):
a) In your Google Webmaster Dashboard > Preferred domain, specify weather Google should show the site as www or non-www.
b) Some web hosting companies allow you to specify this distinction in your admin panel. Some do not.
c) Lastly, you should add the following code to your .hta access file which will redirect
RewriteCond %{HTTP_HOST} ^example\.com
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*[^/])$ http://www.example.com/$1/ [R=301,L]
2) pages like /index.php get redirected to /index.php/ (as discussed here [webmasterworld.com...] ).
You can add the following code to your .htaccess file (* Or see below for a plug-in that does this as well as the next requirement):
#Add / to pages
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*[^/])$ $1/ [R=301,L]
3) www.domain.com/index.php/ redirects to the root directory www.domain.com
OK, Found and installed this nifty plug-in called, "permalink redirect" [fucoder.com...] which replies a 301 permanent redirect, if requested URI is different from entry’s (or archive’s) permalink. It is used to ensure that there is only one URL associated with each blog entry. This accomplishes the requirements #2 & #3.
Note: I also uncover a plug-in called "wordpress duplicate content cure" [seologs.com...] which makes only index, page, and posts indexed via nofollow tags. Conversely, you can also add the following code to your header.php file which works as well:
<?php if(is_home() ¦¦ is_single() ¦¦ is_page()){
echo "<meta name=\"robots\" content=\"index,follow\">";
} else {
echo "<meta name=\"robots\" content=\"noindex,follow\">";
}?>
Whew, what a couple of days ;) Hope this makes someone's life a bit easier.
[edited by: tedster at 12:36 am (utc) on May 4, 2007]
[edit reason] fix link [/edit]
Thanks! That was one of the deep posts I waded through seeking information ;) I was hoping to start a more concise posts so that people (like me) could find the information a little more quickly. Conversely, if I was missing something or made a mistake, the response wouldn't be 15 pages away.