D
D
danil4e2018-10-17 13:16:31
htaccess
danil4e, 2018-10-17 13:16:31

How to redirect to https yii?

Hey! There is htaccess on the site on yii:
RewriteEngine On
RewriteBase /
RedirectMatch 403 /\..*$
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)?$ http://%1 /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Please tell me how to redirect to https?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor L, 2018-10-17
@Fzero0

I have this and it seems to be working

# Mod_Autoindex
<IfModule mod_autoindex.c>
    # Запрещаем просмотр содержимого папок
    Options -Indexes
</IfModule>

# Mod_Rewrite
<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
  
  RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  RewriteRule ^(.*)$ https://%1/$1 [L,R=301]
  
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [L,R=301]
  

    # Backend redirect
    RewriteCond %{REQUEST_URI} ^/backend
    RewriteRule ^backend/(.*)$ backend/web/$1 [L]

    # Storage redirect
    RewriteCond %{REQUEST_URI} ^/storage
    RewriteRule ^storage/(.*)$ storage/$1 [L]
    
    # Frontend redirect
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteRule ^(.*)$ frontend/web/$1
  
</IfModule>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question