Remove .php from url in .htaccess?

I have tried a lot of tiny tricks for removing the .php from a url, but nothing I have tried has worked like I would have hoped. I would like http.php to redirect to http.

What I have I tried:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L,R=301]

and

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

also

RewriteCond %{REQUEST_FILENAME} .php$
RewriteRule ^(.*)$ $1 

and I would like to reiterate that NOTHING WORKS!

Do any of you have a solution?

PS. I do have RewriteEngine on, I know this because my site does redirect to https.

Try this

Options +MultiViews +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} [1]{3,}\s([^.]+).php [NC]
RewriteRule ^ %1 [R,L,NC]


  1. A-Z ↩ī¸Ž

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.