S
S
SidorKovpak2018-04-22 19:13:59
Apache HTTP Server
SidorKovpak, 2018-04-22 19:13:59

How to remove the .php extension at the end of a line in .htaccess?

You need to redirect to the page:
site.ru/login
In the following cases:
site.ru/login.php,
site.ru/login.html
site.ru/login/index.php
I try this:

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

Displays 404.
Page: site.ru/login - loads normally. But you need redirects to it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-04-23
@shambler81

RewriteCond %{REQUEST_METHOD} =GET
   # Выявляем GET запрос в URL (не POST).
RewriteCond %{REQUEST_URI} ^(.*)/index\.php$
   # URL cодержит index.php в конце.
RewriteRule ^(.*)$ %1/ [R=301,L]
   # Удалить index.php из URL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question