H
H
HAbRAhabp2015-10-18 18:57:51
Apache HTTP Server
HAbRAhabp, 2015-10-18 18:57:51

Why doesn't it remove *.php?

Here is my code:

<IfModule mod_rewrite.c>
 RewriteEngine On 
 RewriteBase /  

 # всё что не касается файлов и не имеет точки в названии, добавлять в конце слеш
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_URI} !(.*)\.(.*){1,5}$
 RewriteCond %{REQUEST_URI} !(.*)/$
 RewriteRule ^(.*[^/])$ $1/ [L,R=301]
 
 # делает редирект для  *.php)
 RewriteCond %{REQUEST_URI} ^(.*)\.php$
 RewriteRule ^(.*)\.php$ $1\/ [L,R=301]
 
 # убираем индексы
 RewriteCond %{REQUEST_URI} ^(.*)index.php(.*)$
 RewriteRule ^(.*)index.php(.*)$ $1$2 [L,R=301]
 
 # site.ru/*/ открывает как site.ru/*.php
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME}\.php -f
 RewriteRule ^(.*)(\/)$ %{REQUEST_FILENAME}.php/ [L]

</IfModule>

But for some reason, the main page always opens, and not the requested page.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Matrozov, 2015-10-28
@HAbRAhabp

See what you get in some htaccess tester, for example : htaccess.madewithlove.be would not be quite right. At least fix the line: RewriteRule ^(.*)\.php$ $1\/ [L,R=301] $1\/ replace with $1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question