ErrorDocument 500 http://www.example.com
ErrorDocument 404 http://www.example.com
ErrorDocument 403 http://www.example.com
ErrorDocument 401 http://www.example.com
Noooo! This is wrong in two separate and unrelated ways.
#1 an ErrorDocument directive must never contain an explicit domain name, because that converts the response into a 302 redirect. (This is actually true of any Apache directive that involves a "target".) Instead it should start with a single / representing the root.
#2 you seem to be redirecting everyone to the front page. Search engines and users
both hate this, independent of whether it's configured as a redirect or you're using / as your error document.
Besides, why on earth would you send 403s to the front page? If nothing else, it leads to an infinite loop.
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
The first rule-- the "index.php" redirect-- will not be executed, because it comes before the "RewriteEngine On" directive. The second rule is a domain-name-canonicalization redirect. The Condition should be expressed as
!^(www\.example\.com)?$
meaning "anything
other than my desired form".
You must have another htaccess file somewhere, since there's absolutely nothing in the quoted part that does
#1 what you say you want (redirect .php requests to extensionless)
#2 what you don't want but is happening anyway (redirect extensionless requests to homepage).
Are you positive there isn't a CMS-boilerplate htaccess in some subdirectory? "Redirect all extensionless URLs to the root" is exactly what you'd expect in a built-in CMS htaccess file-- the kind that comes with WordPress, Joomla, Drupal and assorted others I can't think of.