2013-07-27 20 views
1

我有運行Laravel 3一個網站,需要使用Apache配置以下重寫規則,迫使HTTPS:正確Laravel強制HTTPS與現代重寫

RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

這迫使HTTPS,但所有的Laravel路由返回「未找到'(即不擊中index.php),如果我刪除重寫規則一切正常。

的/公共文件夾中的的.htaccess是正常的Laravel:

<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 %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

回答

4

幾個小時的調試後,現在似乎很簡單:我的default-ssl config沒有該行

AllowOverride All 

使htaccess能夠被讀取

+0

太棒了!適用於我。 – TodStoychev

5

這的.htaccess爲我工作:

<IfModule mod_rewrite.c> 
    #Options -MultiViews 
    RewriteEngine On 
    RewriteBase/
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://mysite.com/$1 [R,L] 
</IfModule> 
+0

不幸的是,它不適合我 –

+0

使用'服務器版本:Apache/2.2.22(Ubuntu)'。 –

+0

我解決了它 - 是我的疏忽ssl配置不允許讀取htaccess - 感謝您的幫助 –