N
N
NasekinLovell2021-10-07 16:33:31
htaccess
NasekinLovell, 2021-10-07 16:33:31

How to make a redirect from multiple slashes to the main one?


there is, for example, site.ru site . For

some reason, pages with slashes
site.ru//
site.ru///
site.ru//// site.ru////
site.ru/ are
active?

how to redirect to home page?

Answer the question

In order to leave comments, you need to log in

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

RewriteCond %{THE_REQUEST} //
   # Проверяем, повторяется ли слеш (//) более двух раз.
RewriteCond %{QUERY_STRING} !http(s|)://
  # Убедимся что это не урл в  GET
RewriteRule .* /$0 [R=301,L]
   # Исключаем все лишние слеши.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question