2011-12-24 68 views
1

我有這個.htaccess文件將所有請求重定向到根目錄中的index.php。.htaccess和SSL並重定向到index.php

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !.(jpg|jpeg|gif|png|css|js|pl|txt)$ 
RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^(.*) index.php 

現在我想添加強制http協議爲https。

我該如何更改我的文件?

感謝

+0

的(http://stackoverflow.com/questions/1108706/correctly-switching-between-http-and-https-using-htaccess) –

+0

[HTTP和HTTPS使用。htaccess之間正確的切換]可能重複感謝您的支持,但我認爲我的問題是不同的,或者我不明白您的文章的解決方案。 – John

+1

您是否閱讀過該文章,並嘗試將該文章的解決方案包含到您的htaccess文件中?如果沒有,那就這樣 - 解決方案就在那裏。 –

回答

2

如果你想迫使你的站點的所有請求是安全的,然後在下面的代碼添加到您的.htaccess文件。

RewriteEngine On 
RewriteBase/

#if the request is not secure 
RewriteCond %{HTTPS} off 
#redirect to the secure version 
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L] 

#These are your existing rules 
RewriteCond %{REQUEST_FILENAME} !.(jpg|jpeg|gif|png|css|js|pl|txt)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^(.*) index.php 
相關問題