重写规则将导致403 forbbiden错误 [英] Rewrite rule leads to 403 forbbiden error

查看:132
本文介绍了重写规则将导致403 forbbiden错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也问一个问题,昨天在这里和用户FAA试图帮助我,但遗憾的是我们没能解决问题。

原来的问题就在这里:重写URL以htaccess的当一个目录存在

我做了一个简单的重写,但它不能正常工作(显然),由于目录的访问权限。

的code:

*动态页面:url.com/index.php?page=download

重写规则:^下载$ /index.php?page=download

的问题:

中存在一个名为下载目录中。 当重写规则试图改写动态页面*到路径下载,它返回一个403 FORBBIDEN错误,页面被改写为下载/?页=下载。

现在,如果我重新命名该目录别的东西,如下载,然后它的作品。

- 编辑 -

我的服务器,默认情况下,保护与403 Forbbiden错误的每个目录。我相信,这就是为什么它不工作的原因,但我不知道。 它是一个矛盾真的是吗? 这是怎么回事?

解决方案
  

/下载/?页=下载

为什么发生这种情况的原因是什么地方mod_dir重定向对于那些缺少尾随斜线后面的斜线目录的所有请求。这是interferring你重写规则。因为你的服务器会自动设置为拒绝目录的上市,它可能是安全的,继续前进,把目录斜线关闭:

  DirectorySlash关闭
 

I have asked a question here yesterday and user "faa" tried to help me, but unfortunately we couldn't solve the issue.

Original question is here: Rewriting url with htaccess when a directory exists

I am doing a simple rewrite but it is not working (apparently) due to directory access permissions.

The Code:

*Dynamic Page: url.com/index.php?page=download

Rewrite Rule: ^download$ /index.php?page=download

The problem:

A directory named "download" exists. When the rewrite rule tries rewrite the Dynamic Page* to the path "download", it returns a 403 FORBBIDEN error and the page gets rewritten to "download/?page=download".

Now, if I rename that directory to something else, like "downloads", then it works.

-- EDIT --

My server, by default, protects every directory with a "403 Forbbiden Error". I believe this is the reason why it's not working, but I'm not sure. Is it a conflict indeed? What is happening?

解决方案

/download/?page=download

The reason why this is happening is because somewhere mod_dir redirects all requests for directories that are missing the trailing slash to include the trailing slash. This is interferring with your rewrite rule. Since your server is automatically setup to deny listing of directories, it's probably safe to go ahead and turn directory slashes off:

DirectorySlash Off

这篇关于重写规则将导致403 forbbiden错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆