Try something like the following at the top of your .htaccess
file:
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+)\.php$ /$1 [R=302,L]
The above redirects any URL that ends in .php
that does not map to a physical file and removes the .php
extension in the redirection.
Although these requests (with a .php
extension) shouldn’t be triggering a 500 error in the first place? If the above redirect resolves this, then it would seem to imply that it is WordPress itself that is triggering the 500 error?
I used this code to remove the .php extension
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ / [L,QSA] </IfModule>
This resolved the 500 error …
This code is more likely to cause a 500 error than fix it? This doesn’t “remove the .php
extension” – it simply routes all URLs to the document root, which triggers mod_dir to route the request to index.php
.