0
我在Centos 6.6上運行Apache/2.2.15,並使用StartCom提供的免費證書。我的主頁文件是/var/www/index.php,所以我創建了一個文件/var/www/.htaccess,內容如下,建議爲here。.htaccess未將網站重定向到https
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
然而,在URL框中輸入
myWebSite.com
帶來了我的http協議的網站。如果我輸入
https://myWebSite.com
改爲,我在https協議中獲取我的網站。我的目標是,簡單地輸入
myWebSite.com
,我看不出爲什麼.htaccess文件沒有影響,要得到我的https協議的網站。
你確定你的.htaccess正在被讀取嗎?你的配置中有'AllowOverride All'嗎? –
修復了原始問題。現在,當我進入mywebsite.com時,我得到「該頁面沒有正確重定向,Firefox檢測到服務器正以一種永遠不會完成的方式重定向該地址的請求。」我以前沒有遇到過這個問題。我的.htaccess文件有問題嗎?謝謝, – OtagoHarbour
您在嘗試我的答案之前或之後是否有此錯誤? –