【问题标题】:Issue with accessing https访问 https 的问题
【发布时间】:2016-12-20 06:59:38
【问题描述】:

我在 Laravel 中构建了一个应用程序,但在通过 https 访问页面时遇到问题。例如,如果我访问 geepay.in,应用会重定向到 https

但是,如果我访问 http://geepay.in/9860494211,它会重定向到 https 域 index.php

(另外,如果我从 htacess 中删除脚本,应用程序将停止工作并引发错误)。

我的 htacess 文件包含以下内容

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

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

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

</IfModule>

AddHandler application/x-httpd-php55  .php55 .php

我该如何解决这个问题?

【问题讨论】:

  • 你遇到什么错误

标签: .htaccess http-redirect


【解决方案1】:

您只需通过交换重写和 https 重定向来解决此问题。在您的情况下,Apache 将首先匹配规则 2。然后规则 1 和 2 不再匹配,您匹配规则 3。由于您已经重写了 url,因此您使用重写的 url 执行重定向。

如果您交换规则,重定向将首先匹配。之后,新请求将匹配您的规则 2(然后是 3),并让 Laravel 处理该请求。

【讨论】:

    猜你喜欢
    • 2021-10-11
    • 2015-07-22
    • 2011-03-31
    • 2010-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-29
    • 1970-01-01
    相关资源
    最近更新 更多