gpt4 book ai didi

php - htaccess 尾部斜线问题

转载 作者:搜寻专家 更新时间:2023-10-31 21:27:34 25 4
gpt4 key购买 nike

我遇到了一些问题,因为没有结尾的斜杠 url。我在 Google 中进行了搜索,但未能获得准确的结果。

  From Url : local.xxxx.com/stories

当我尝试使用上面的 Url 时,它会重定向到

  To Url : local.xxxx.com/sapp/View//stories/

访问:

DirectorySlash Off
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -d
RewriteRule ^ /app/View/%{REQUEST_URI} [L]

现在我收到 403 Forbidden 错误。您无权访问此服务器上的/app/View//stories。

如果我将添加尾部斜线,那么它会完美地工作。如果没有斜杠,我们可以在没有参数的情况下在url末尾添加斜杠。

任何人都可以建议我如何实现这一目标。

最佳答案

这很可能是因为 /app/View/stories/ 是一个真实的目录,而 Apache 的 mod_dir 添加了一个尾部斜杠。

您可以使用此代码修复:

DirectorySlash Off
RewriteEngine On

# internally add a trailing slash to directories
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -d
RewriteRule [^/]$ /app/View/%{REQUEST_URI}/ [L]

RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -d
RewriteRule ^ /app/View/%{REQUEST_URI} [L]

关于php - htaccess 尾部斜线问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33931767/

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