Skip to content

Instantly share code, notes, and snippets.

@leotop
Forked from s2ar/.htaccess_slash
Created April 25, 2017 23:03
Show Gist options
  • Save leotop/be893cbb558008c529f29e75246b4686 to your computer and use it in GitHub Desktop.
Save leotop/be893cbb558008c529f29e75246b4686 to your computer and use it in GitHub Desktop.
Убрать слеши в htaccess
#Правило обрабатывает внутренние страницы
# http://site.ru/catalog////item///
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
#Проверяем, повторяется ли слеш (//) более двух раз.
RewriteRule . %1/%2 [R=301,L]
#Исключаем все лишние слеши.
#удаляем слеши для главной http://site.ru/////
RewriteCond %{THE_REQUEST} ([^\s]*)\/{2,}(\?[^\s]*)?
RewriteRule (.*) / [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment