Answer the question
In order to leave comments, you need to log in
How to set the redirect condition of several / (slashes) to 1 in the htacces file in RewriteCond?
Good afternoon!
The question arose of redirecting several slashes to one.
With this code, we were able to remove the extra / (slashes) at the end of the URL:
# Убираем повторяющиеся слеши (/) в URL
RewriteCond %{THE_REQUEST} ([^\s]*)\/{2,}(\?[^\s]*)?
RewriteRule (.*) %1 [R=301,L]
# END Убираем повторяющиеся слеши (/) в URL
Answer the question
In order to leave comments, you need to log in
https://klondike-studio.ru/standards/standartnyy-h... I
wrote in detail here.
If right for the task then
RewriteCond %{THE_REQUEST} //
# Проверяем, повторяется ли слеш (//) более двух раз.
RewriteCond %{QUERY_STRING} !http(s|)://
# Убедимся что это не урл в GET
RewriteRule .* /$0 [R=301,L]
# Исключаем все лишние слеши.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question