htaccess尾部斜杠问题

罗伯特

我在没有尾随斜杠网址的情况下遇到了一些问题。我在Google中搜索,但无法获得确切结果。

  From Url : local.xxxx.com/stories

当我尝试使用上述网址时,它重定向到

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

htaccess:

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禁止错误。您无权访问此服务器上的/ app / View // stories。

如果我要添加斜杠,那么它可以正常工作。如果没有斜杠,则可以在没有参数的情况下在网址末尾添加斜杠。

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

阿努巴瓦

这很可能是由于它是/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]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章