I
I
Igor Almazov2020-06-17 18:38:27
htaccess
Igor Almazov, 2020-06-17 18:38:27

I can’t transfer the site to https, the site is written in YII2, below is .htaccess which is at the root. What additional information needs to be added to the file?

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# If request starts with /admin, then change to /backend/web/
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin\/?(.*) /backend/web/$1

# Add another request /frontend/web/$1
RewriteCond %{REQUEST_URI} !^/(frontend/web|backend/web|admin)
RewriteRule (.*) /frontend/web/$1

# If frontend request is
RewriteCond %{REQUEST_URI} ^/ frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /frontend/web/index.php

# If backend request
RewriteCond %{REQUEST_URI} ^/backend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /backend/web/index.php

When I add these lines, the site works but styles fall off and JS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mario Kun, 2020-06-18
@snake-snake

First of all, on the hosting side.
1 Install an SSL certificate (Let's Crypt is free)
2 Set up an automatic redirect to https
All this is done in the hosting control panel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question