Forum Moderators: phranque
However, I think my code is causing google problems to crawl my site. This is the content of my .htaccess file?
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]# Redirect index.php to domain.com
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
The second section is a cut and paste job from one of the threads here, but since including it, I have been getting errors in my sitemaps reporting.
Any help is appreciated!
The only way this might cause a problem with GWT Sitemaps is if some of your pages link to "/index.php" instead of to "/". Once you've installed this code, you should never link on your own site to "/index.php". You should consistently link only to "/".
Also, the code will not rewrite "/index.php" to "/" if the request for index.php has a query string appended to it. It will also rewrite only the /index.php file only in your top-level directory, and no others. You'll have to decide if that is what you want or not.
Jim
A request for domain.com/index.php will be redirected to www.domain.com/index.php and then that will again be redirected to www.domain.com. You need to avoid just such a redirection chain.
The solution is simple. Put the more specific redirect rule first, with that rule not just forcing the index page to "/", but make it also force the www at the same too.
The second rule will then force all remaining domain.com URLs to the www version. This rule will not run for index pages. The first rule will have already taken care of them.