簡體   English   中英

無法使用.htaccess強制使用SSL / https

[英]Unable to Force SSL/https using .htaccess

我在主機上使用開放學校php,並且試圖在我的網站上強制使用ssl,但是當我添加此代碼時

     RewriteEngine On 
     RewriteCond %{SERVER_PORT} 80 
     RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

但隨后我無法訪問我的網站,因為瀏覽器顯示太多循環或重定向

頁面未正確重定向

Firefox已檢測到服務器正在以永遠無法完成的方式重定向對該地址的請求。

這是原始的htacess文件,請幫助

    Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On


#Admin
Rewriterule ^admin$ index.php?r=Cms/admin/home
#Install
Rewriterule ^install$ install.php?r=Install/default

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(js|ico|gif|jpg|png|css)$

# otherwise forward it to index.php
RewriteRule . index.php

而不是使用%{SERVER_PORT}行,請嘗試以下操作:

RewriteCond %{HTTPS} !=on

這是一個完整的.htaccess文件,我用來強制任何網站使用SSL:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM