治疗指数和的index.php作为同一文件 [英] Treating index and index.php as the same file

查看:162
本文介绍了治疗指数和的index.php作为同一文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache 2.2.22和PHP 5.3.10 PHP项目,我跑到那里指数和index.php文件被视为同一文件中的问题。

我有一个管理/ index.php文件重定向到管理员/指数,以允许在.htaccess我mod_rewrite规则接管并重新路由请求到一个自定义的框架。问题是,当浏览器去管理/索引它进入一个无限重定向循环,因为该请求被发送到管理员/ index.php文件会被重定向到管理员/指数

我试图消除htaccess文件,看看是否有与我的mod_rewrite规则的一个问题,是造成它并没有改变任何东西。它只是重定向到管理员/指数不休。

我从来没有听说过这种行为之前,一掠而过一些谷歌的结果和略读通过Apache的配置文件并没有显示任何东西真的很明显。有没有人见过这个,知道如何解决它?

编辑: 下面正由在index.php的code键重定向到索引

 < PHP
    标题(位置:首页);
    死();
 

解决方案

这可能是由于多视图被启用:

  

多视图的效果如下:如果服务器接收到一个   要求/一些/ DIR /富,如果/一些/目录启用了多视图,以及   /一些/目录/ foo的不存在,那么服务器读取目录   寻找名为foo。*的文件,并有效假货一个类型的地图   这名所有这些文件,赋予它们不同的介质类型和   内容编码它会如果客户曾要求之一   他们的名字。然后选择客户的最佳匹配   要求。

     

- https://httpd.apache.org/docs/2.2 /content-negotiation.html#multiviews

尝试添加选项-MultiViews 的.htaccess

I'm working on a PHP project using Apache 2.2.22 and PHP 5.3.10 and I'm running into an issue where index and index.php are being treated as the same file.

I have an admin/index.php that redirects to admin/index to allow my mod_rewrite rules in .htaccess to take over and reroute the request into a custom framework. The problem is, when the browser goes to admin/index it goes into an infinite redirect loop because the request is being sent to admin/index.php which redirects to admin/index

I've tried removing the htaccess file to see if there was a problem with my mod_rewrite rules that was causing it and it didn't change anything. It just redirects to admin/index endlessly.

I've never heard of this behavior before, skimming over some Google results and skimming through the apache configuration files didn't show anything really obvious. Has anyone seen this before and know how to fix it?

EDIT: Below is the code being used by the index.php to redirect to index.

<?php
    header("Location: index");
    die();

解决方案

This may be due to MultiViews being enabled:

The effect of MultiViews is as follows: if the server receives a request for /some/dir/foo, if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements.

https://httpd.apache.org/docs/2.2/content-negotiation.html#multiviews

Try adding Options -MultiViews to your .htaccess

这篇关于治疗指数和的index.php作为同一文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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