how to remove .php extension using htaccess on godaddy linux hosting

Solution 1:

The question is missing example URLs, which is really essential for diagnosing such problems, however...

# Resolve .php file for extensionless php urls 
RewriteRule ^([^/.]+)$ $1.php [L]

This only matches URLs with single path segments, ie. URLs that are effectively in the document root, eg. /foo. It won't match URLs with multiple path segments, ie. URLs that are effectively in subdirectories eg. /foo/bar - which would explain why you are getting 404s for "php files inside the subfolder".

You need to remove the slash in the RewriteRule pattern, in order to match any URL depth:

RewriteRule ^([^.]+)$ $1.php [L]

By including a slash in the negated character class you are only matching URLs that don't contain a slash. ie. URLs in the document root only.

(There is no need to backslash escape a literal dot when used inside a character class.)