G
G
Grione2021-02-02 10:57:29
Nginx
Grione, 2021-02-02 10:57:29

Why does a 301 redirect give an error 400 Bad Request The plain HTTP request was sent to HTTPS port?

Good afternoon everyone.
Site on Bitrix. There was a task to change the directory structure a bit, because of this, you need to redirect from several old pages to new ones.
In .htaccess I write the following structure:
Redirect 301 /catalog/opory-osveshchenyia/opory-osveshcheniya-nesilovye/opory-osveshcheniya-ogk/ /catalog/opory-osveshchenyia/opory-osveshcheniya-nesilovye/granenye-opory/

And then if you open the first the address from which the redirect should be, it gives an error:
400 Bad Request
The plain HTTP request was sent to HTTPS port
nginx/1.18.0
At the same time, the address for some reason with http. If you manually change to https, then everything works.

Here is the whole .htaccess

Options -Indexes 
ErrorDocument 404 /404.php

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

  #php_value display_errors 1

  #php_value mbstring.internal_encoding UTF-8
</IfModule>

<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots.txt

RewriteCond %{HTTP_HOST} kazan.toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots_kazan.txt

RewriteCond %{HTTP_HOST} krasnodar.toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots_krasnodar.txt

RewriteCond %{HTTP_HOST} novosibirsk.toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots_novosibirsk.txt

RewriteCond %{HTTP_HOST} sankt-peterburg.toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots_sankt_peterburg.txt

RewriteCond %{HTTP_HOST} vladivostok.toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots_vladivostok.txt

RewriteCond %{HTTP_HOST} almaty.toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots_almaty.txt

RewriteCond %{HTTP_HOST} nursultan.toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots_nursultan.txt

RewriteCond %{HTTP_HOST} moskva.toenergo.ru
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule ^(.*)$ robots_moskva.txt



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}]
</IfModule>

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

# Упорядочивание категорий от 1.02.2021 #

Redirect 301 /catalog/opory-osveshchenyia/opory-osveshcheniya-nesilovye/opory-osveshcheniya-ogk/ /catalog/opory-osveshchenyia/opory-osveshcheniya-nesilovye/granenye-opory/



<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"

AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType application/x-font-woff .woff2
AddType video/webm .webm

ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType application/x-shockwave-flash "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
ExpiresByType text/html "access plus 1 year"
ExpiresByType application/xhtml+xml "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"

</IfModule>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question