【问题标题】:Laravel SSL .htaccess redirection to index.phpLaravel SSL .htaccess 重定向到 index.php
【发布时间】:2018-05-27 02:57:48
【问题描述】:

我的 laravel 5 应用程序出现重定向问题。我将 .htaccess 配置为使用 SSL - 它运行良好。问题是当我输入时:

example.com/page - 应该显示page 路由但浏览器重定向到https://example.com/index.php

当我在浏览器中输入完整地址时,例如 https://example.com/page 路由运行良好,例如。在浏览器中,我看到了我的 page 路线(刀片,itp)。 有什么问题?

我的.htaacess 文件

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    order deny,allow
    deny from all

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

</IfModule>

【问题讨论】:

    标签: apache laravel .htaccess ssl mod-rewrite


    【解决方案1】:

    只需在“Handle Front Controller”之前编写“Handle 授权标头”

    # Handle Authorization Header
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    否则,如果有http到https的重定向,将无法到达主前端控制器的转换。

    【讨论】:

      【解决方案2】:

      正如@Amarnasan 所提到的,但如果它仍然不起作用,请删除浏览器的缓存,然后它应该可以工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-01-21
        • 2014-08-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-28
        相关资源
        最近更新 更多