M
M
Maxim2019-09-27 05:50:49
htaccess
Maxim, 2019-09-27 05:50:49

How to make a 301 (not 302) redirect from HTTP to HTTPS in .htaccess?

On the site being promoted, a redirect from HTTP to HTTPS is configured in .htaccess with the following code:

RewriteEngine on
RewriteCond %{HTTPS} =off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]

Using the https://burtik.com/ service , I saw that there was a 302 redirect, and I need exactly 301.
Please help me figure it out and choose the right code so that the redirect gives the 301 code.
PS. Site on drupal 8.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-09-27
@MToUCH

RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question