URL Rewriting - Redirect With No File Extension URL Rewriting - Redirect With No File Extension apache apache

URL Rewriting - Redirect With No File Extension


Try this rule to redirect requests for .php files:

RewriteCond %{THE_REQUEST} ^GET\ /(([^/?]*/)*[^/?]+)\.phpRewriteRule ^.+\.php$ /%1 [L,R=301]


Could you just change your last RewriteRule to do this?

RewriteRule ^(.*)$ $1.php [L,R=301]

That will redirect "myfile" to "myfile.php".

Also, you can adjust for this inside of Google Analytics using rules as well. Although that probably isn't an ideal solution.

ETA: If you want myfile.php to redirect to myfile, try this for your last rule instead:

RewriteRule ^(.+)\.php$ $1 [L,R=301]