W
W
WebforSelf2022-04-04 17:12:08
htaccess
WebforSelf, 2022-04-04 17:12:08

How to set a redirect correctly?

Tell me how to set up redirects,
Main site
https://www.site.ru

Accordingly, I need from www to without www
and from http to https

in htaccess

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

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

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

RewriteCond %{HTTP_HOST} ^www.site.ru\.index\.php?module=MainView&page_url=
RewriteRule ^(.*)$ https://www.site.ru/ [R=permanent,L]


624afc0b32995787441966.png
As a result, a 302 redirect is taken from somewhere through the verification service .
And like this
In general, a 302 redirect occurs with http
624afc8c0fcbb986723577.png

Tried this option
RewriteEngine On
RewriteCond %{HTTP_HOST} ^сайт\.ru$ [NC]
RewriteRule ^(.*)$ https://www.сайт.ru/$1 [L,R=301]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

without changes

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