Redirect from http to https for OkayCMS
Recently, the popularity of the https protocol has grown very much, as it has a very good effect on the site's reputation "in the eyes of a search robot.
That is why we are posting for free access several ways to redirect from http to https for OkayCMS.
We make edits to the .htaccess file, put the following redirects in front of the redirect to the admin panel
Attention! On some hosting, the methods may differ, I will give a few, in order of popularity.
Method 1. Works exactly on 60% hosting (ukraine.com.ua and Timeweb are verified)
RewriteBase /
RewriteCond% {HTTP: SSL}! = 1 [NC]
RewriteRule ^ (. *) Https://new_domain.com/$1 [L, R = 301]
Method 2.
RewriteEngine On
RewriteCond% {HTTPS} off
RewriteCond% {HTTP: X-Forwarded-Proto}! Https
RewriteRule ^ (. *) $ Https: //% {HTTP_HOST}% {REQUEST_URI} [L, R = 301]
Method 3. (off. Information from hosting REG.RU)
RewriteEngine On
RewriteCond% {HTTPS} = on
RewriteRule (. *) Https: //% {HTTP_HOST}% {REQUEST_URI} [QSA, L]
Comments
5
Варіант #2 - не працює (кидає в 500-ту)
Рішення:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTP:X-HTTPS} !1 [OR]
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !robots\.txt
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#RewriteBase /