This is probably caused by the way PHP is installed/routed on your system. If you check the HTTP response headers of the "File not found" response, I guess you will see this is from a different/proxy server (perhaps Nginx)?
However, you shouldn't be blindly rewriting requests to .php when the original request simply does not exist. (/home1 is first being internally rewritten to /home1.php, which is then triggering a 404, not /home1 - the original request.) You should instead be checking that <requested-url>.php exists before rewriting the request.
For example, try the following instead:
RewriteCond %{DOCUMENT_ROOT}/$1.php -f RewriteRule ^([^.]+)$ $1.php [L]
Additional notes...
- In
.htaccess you don't need the PT (pass through) flag, since that is the default action. - No need to backslash-escape a literal dot when used inside a regex character class.
- No need to check that the request does not map to a directory, unless you happen to have a directory of the same name as the
.php file basename - but that itself creates a conflict as /<requested-url>.php will not be accessible.
ErrorDocument 404 http://example.com/404.php ErrorDocument 403 http://example.com/403.php
By specifying an absolute URL in the ErrorDocument directive this will result in a 302 (temporary) redirect to the error document and the original HTTP error status will be lost. (ie. the client sees a 302, not a 404 - bad for users and SEO.)
(And HTTP, not HTTPS?)
This should generally be written using root-relative URL-paths in order to trigger an internal subrequest for the error document (thus preserving information from the original request), not an external redirect. For example:
ErrorDocument 404 /404.php ErrorDocument 403 /403.php
/home1nor/home1.phpexists. That is to be expected and correct. Why do you say " htaccess rule not working here"? To me it looks like the rule does get applied, but/home1.phpdoes not exist. What else should the server respond, if not a 404?/404.php.RewriteRule, but to theErrorDocumentdirective.