2016-09-15 37 views
0

我的Laravel項目已經在共享託管服務器(我知道你在想什麼...)。而根文件夾中我得到了它有這個代碼.htaccess文件:htaccess的Laravel公用文件夾使用https ONLY

<IfModule mod_rewrite.c> 
Options +FollowSymLinks 
RewriteEngine On 
</IfModule> 
# For all files not found in the file system, reroute the request to the 
# "index.php" front controller, keeping the query string intact 
<IfModule mod_rewrite.c> 
RewriteCond $1 !^(public) 
RewriteRule ^(.*)$ /public/$1 [L] 
</IfModule> 

這給了我很好的URL沒有「公共」,但有一個情況: 如果我去:

www.example.com 

所以它總是與網址WWW保持.....如果我去:

https://www.example.com 

它總是保持與URL https://開頭....

我的問題: 如何使URL始終爲https://www.example.com無論我首先輸入www還是https?

回答

0

這應該這樣做:

RewriteCond %{HTTPS} !=on 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
相關問題