K
K
kamisarlapsha2018-07-10 03:58:24
htaccess
kamisarlapsha, 2018-07-10 03:58:24

How to remove the .php extension?

It is impossible to remove the extension in any way.

RewriteEngine On
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]

Error 404 - The requested URL /works/.php was not found on this server.
And even more desirable, you can suggest to remove the cloned pages. To be only without the extension.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-07-10
@shambler81

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question