D
D
DeeUs2017-08-28 14:49:03
1C-Bitrix
DeeUs, 2017-08-28 14:49:03

Why are slashes added after converting url to lowercase?

Here is the content of htaccess

the code
Options -Indexes
ErrorDocument 404 /404.php

RewriteEngine On
RewriteBase /
# Если есть прописные буквы, установить HASCAPS в true и пропустить следующее правило
RewriteRule [A-Z] - [E=HASCAPS:TRUE,S=1]
# Пропустить этот раздел в случае, если в URL нет букв в верхнем регистре
RewriteRule ![A-Z] - [S=28]
# Заменить одно вхождение слова "CAP" на "cap" и перейти к следующему правилу.
RewriteRule ^([^A]*)A(.*)$ $1a$2
RewriteRule ^([^B]*)B(.*)$ $1b$2
RewriteRule ^([^C]*)C(.*)$ $1c$2
RewriteRule ^([^D]*)D(.*)$ $1d$2
RewriteRule ^([^E]*)E(.*)$ $1e$2
RewriteRule ^([^F]*)F(.*)$ $1f$2
RewriteRule ^([^G]*)G(.*)$ $1g$2
RewriteRule ^([^H]*)H(.*)$ $1h$2
RewriteRule ^([^I]*)I(.*)$ $1i$2
RewriteRule ^([^J]*)J(.*)$ $1j$2
RewriteRule ^([^K]*)K(.*)$ $1k$2
RewriteRule ^([^L]*)L(.*)$ $1l$2
RewriteRule ^([^M]*)M(.*)$ $1m$2
RewriteRule ^([^N]*)N(.*)$ $1n$2
RewriteRule ^([^O]*)O(.*)$ $1o$2
RewriteRule ^([^P]*)P(.*)$ $1p$2
RewriteRule ^([^Q]*)Q(.*)$ $1q$2
RewriteRule ^([^R]*)R(.*)$ $1r$2
RewriteRule ^([^S]*)S(.*)$ $1s$2
RewriteRule ^([^T]*)T(.*)$ $1t$2
RewriteRule ^([^U]*)U(.*)$ $1u$2
RewriteRule ^([^V]*)V(.*)$ $1v$2
RewriteRule ^([^W]*)W(.*)$ $1w$2
RewriteRule ^([^X]*)X(.*)$ $1x$2
RewriteRule ^([^Y]*)Y(.*)$ $1y$2
RewriteRule ^([^Z]*)Z(.*)$ $1z$2
# Если есть буквы в верхнем регистре, начать заново с самого первого RewriteRule в файле.
RewriteRule [A-Z] - [N]
RewriteCond %{ENV:HASCAPS} TRUE

RewriteRule ^/?(.*) /$1 [R=301,L]

<IfModule mod_php5.c>
  php_flag allow_call_time_pass_reference 1
  php_flag session.use_trans_sid off
</IfModule>

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
 RewriteCond %{HTTP_HOST} ^www\.site\.ru$ [NC]
 RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} [\xC2-\xDF][\x80-\xBF] [OR]
RewriteCond %{REQUEST_FILENAME} \xE0[\xA0-\xBF][\x80-\xBF] [OR]
RewriteCond %{REQUEST_FILENAME} [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} [OR]
RewriteCond %{REQUEST_FILENAME} \xED[\x80-\x9F][\x80-\xBF] [OR]
RewriteCond %{REQUEST_FILENAME} \xF0[\x90-\xBF][\x80-\xBF]{2} [OR]
RewriteCond %{REQUEST_FILENAME} [\xF1-\xF3][\x80-\xBF]{3} [OR]
RewriteCond %{REQUEST_FILENAME} \xF4[\x80-\x8F][\x80-\xBF]{2}
RewriteCond %{REQUEST_FILENAME} !/bitrix/virtual_file_system.php$
RewriteRule ^(.*)$ /bitrix/virtual_file_system.php [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
  RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
  RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]

  RewriteCond %{REQUEST_URI} (.*/[^/.]+)($|\?)
  RewriteRule .* %1/ [R=301,L]
</IfModule>

<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType image/jpeg "access plus 3 day"
  ExpiresByType image/gif "access plus 3 day"
</IfModule>


To remove extra slashes, immediately after converting to lower case, I tried to write
the code
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule . %1/%2 [R=301,L]


This code works, but in this case there are several redirects that gradually remove slashes (I look through bretal),
for example, take a url - these are the 301 redirects that occur if you add the code to remove slashes above:http://site.ru/products/categORY/
http://site.ru/products/category///
http://site.ru/products/categpry//
http://site.ru/products/category/

and here it redirects if you remove it
http://site.ru/products/categORY///

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DeeUs, 2017-08-29
@DeeUs

solved the problem in this way (translated the url to lower case in this way)
https://www.simonholywell.com/post/2012/11/force-l...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question