确定Apache/PHP提供了错误的文件 [英] Apache/PHP is determined to serve the wrong file

查看:60
本文介绍了确定Apache/PHP提供了错误的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用url之类的页面调用 http://testserver/path/to/foo/bar/ 但是apache总共提供了错误的文件.

I have a page that is called with a url like http://testserver/path/to/foo/bar/ but apache is serving the wrong file altogether.

/path/to/是所有代码和.htaccess文件所在的真实目录.应该使用RewriteRulefoo/bar/重定向到foo_bar.php,但是它永远不会到达那里.这不是一个mod_rewrite问题,因为我已注释掉所有可能会干扰的规则,应该为该请求提供404,但是发生相同的问题:

/path/to/ is a real directory where all the code and .htaccess file is. foo/bar/ is supposed to redirect to foo_bar.php with a RewriteRule, but it never gets there. It's not a mod_rewrite issue as I have commented out all the rules that could be interfering, which should give me 404s for that request, but the same problem occurs:

提供的文件是/path/to/foo.php,因此我在其中var_dump $_SERVER并得到:
REQUEST_URI = /path/to/foo/bar/
SCRIPT_NAME = /path/to/foo.php
SCRIPT_FILENAME = /real/path/to/foo.php
PATH_INFO = /bar/
PATH_TRANSLATED = /real/bar/
PHP_SELF = /path/to/foo.php/bar/

the file that is served is /path/to/foo.php, so in it I var_dump $_SERVER and get:
REQUEST_URI = /path/to/foo/bar/
SCRIPT_NAME = /path/to/foo.php
SCRIPT_FILENAME = /real/path/to/foo.php
PATH_INFO = /bar/
PATH_TRANSLATED = /real/bar/
PHP_SELF = /path/to/foo.php/bar/

为什么此请求完全路由到该文件?

Why is this request being routed to this file at all?

推荐答案

您是否具有

Do you have mod_negotiation installed? If so, that'll take your request and try to work out what file you really meant. Unfortunately mod_negotiation gets confused by the reroute-magic from mod_rewrite, so make sure you disable mod_negotiation's MultiViews option when you try to rewrite the request.

如果覆盖设置允许,则可以在.htaccess文件中使用Options -MultiViews禁用MultiViews.

If your overwrite settings allow it, you can disable MultiViews with: Options -MultiViews in your .htaccess file.

这篇关于确定Apache/PHP提供了错误的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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