gpt4 book ai didi

apache - Laravel SSL .htaccess 重定向到 index.php

转载 作者:太空宇宙 更新时间:2023-11-03 12:49:03 25 4
gpt4 key购买 nike

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

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

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

我的.htaac​​ess 文件

<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>

最佳答案

只需在“Handle Front Controller”之前编写“Handle authorization header”

# 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 的重定向,将无法实现主要的前端 Controller 转换。

关于apache - Laravel SSL .htaccess 重定向到 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47789306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com