H
H
Helen29012020-12-25 00:23:05
htaccess
Helen2901, 2020-12-25 00:23:05

Does the htacess rule work correctly for one link but not for another?

There is such a htacess rule that removes multiple slashes correctly without extra
http which looks something like
5fd74fdb38df1635732213.png
this, the rule itself is

RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]



everything is correct with it and this http is not there,
5fe506ed00264218221446.png

but for some reason it works correctly for
site.ru//// and kiev.site.ru//////
and if the link is from some page, for example,
in the kiev.site.ru format /4987/pc/3800000////////
then this http appears again.
5fe506860f4a8682578203.png

Now, if that's all htacess, maybe it's some other rule that conflicts
#order deny,allow
#deny from all

RewriteEngine On
   #  Директива включает редиректы !!!!
RewriteBase / 
   # Без директивы "(.*) = /$1" будет /var/wwww/site/web/$1  с директивой  = /$1
Options +FollowSymLinks
   # Разрешает переход по символическим ссылкам.


php_value error_reporting 1

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L]

#RewriteCond %{REQUEST_URI} !^/$
#RewriteCond %{REQUEST_URI} (.*)/$
#RewriteRule . %1 [R=301,L,E=NS:1,QSA]

RewriteCond %{REQUEST_URI} ^\/$
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]


RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

   RewriteCond %{REQUEST_URI} \..+$
   # Если файл содержит точку.
RewriteCond %{REQUEST_FILENAME} !-d
   # И это не директория.
RewriteCond %{REQUEST_FILENAME} -f
   # Является файлом.
RewriteCond %{REQUEST_URI} ^(.+)/$
   # И в конце URL есть слеш.
RewriteRule ^(.+)/$ /$1 [R=301,L]
   # Исключить слеш.



# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

Redirect 301 /site/index /

RewriteCond %{REQUEST_URI} !^/generate-webp.php$ 
RewriteCond %{REQUEST_URI} !^/sitemap.php$ 
RewriteCond %{REQUEST_URI} !^/php.php$ 
RewriteCond %{REQUEST_URI} !^/allJS\.php?v2$ 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
RewriteRule ^ %1 [R,L,NC]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-12-25
@Helen2901

For "/4987/pc/3800000////////" the rule is triggered:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

It /$1lacks an explicit indication of https: //
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question