Answer the question
In order to leave comments, you need to log in
How to make a redirect from http to https for a site on YII2 (basic) using .htaccess?
Good afternoon, dear experts!
There is a site on YII2 basic
htaccess at the root of the site:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*) /web/assets/$1 [L]
RewriteRule ^css/(.*) /web/css/$1 [L]
RewriteRule ^scss/(.*) /web/scss/$1 [L]
RewriteRule ^js/(.*) /web/js/$1 [L]
RewriteRule ^img/(.*) /web/img/$1 [L]
RewriteRule ^fonts/(.*) /web/fonts/$1 [L]
RewriteRule (.*) /web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Answer the question
In order to leave comments, you need to log in
Thank you for your attention!
The problem was solved as follows: .htaccess, which is in the root of the public folder, edited:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
#enable HTTPS only
#RewriteCond %{HTTPS} !=on
#RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
#remove WWW
#RewriteCond %{HTTP_HOST} ^www\.site\.ru$ [NC]
#RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*) /web/assets/$1 [L]
RewriteRule ^css/(.*) /web/css/$1 [L]
RewriteRule ^scss/(.*) /web/scss/$1 [L]
RewriteRule ^js/(.*) /web/js/$1 [L]
RewriteRule ^img/(.*) /web/img/$1 [L]
RewriteRule ^fonts/(.*) /web/fonts/$1 [L]
RewriteRule (.*) /web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question