I recently added this little code to my file .htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
Well, I understand what is happening here, I think. This little code to remove PHP file extensions causes a loop if the document is not found. This loop causes a server 500 error instead of the (correct) 404. Unfortunately, I understand very little what these rewrites actually do, so I don’t know how to rewrite it to initiate this redirection only if the document exists.
I did some reading, and I'm not sure what Apache considers a “regular” file. I mean this works, but why would the first line not be -finstead !-f? Is the -uonly way to achieve this?
source
share