E
E
Eugene M2018-09-24 10:14:58
htaccess
Eugene M, 2018-09-24 10:14:58

How to correctly write a rule in .htaccess?

This rule almost works as it should, but when redirecting, it adds extra paths to the URL (/home/bitrix/www/) 85.236.13.62/home/bitrix/www/internet-magazin/fold... , which causes a 404 error how to fix it so that these paths are not substituted (/home/bitrix/www/)

#### Добавляем слеш(/), если его нет, и это не файл.
RewriteCond %{REQUEST_URI} !(.*)/$
   # Если слеша в конце нет.
RewriteCond %{REQUEST_FILENAME} !-f
   # Не является файлом.
RewriteCond %{REQUEST_URI} !\..+$
   # В URL нет точки (файл).
RewriteRule ^(.*)$ $1/ [L,R=301]
   # Добавляем слеш в конце.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-09-24
@hotwind

You must explicitly specify the address relative to the site root.
$1/replaced by/$1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question