1

我有一个运行 Laravel 3 的站点,它需要在 apache 配置中使用以下重写规则强制 https:

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

这会正确强制 https,但所有 Laravel 路由都返回“未找到”(即未命中 index.php),如果我删除重写规则一切正常。

/public 文件夹中的 .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

2 回答 2

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>
于 2013-07-27T15:06:32.527 回答
4

经过几个小时的调试,现在看起来很简单:我的 default-ssl 配置没有该行

AllowOverride All

启用要读取的 htaccess

于 2013-07-27T18:36:10.967 回答