条件目录索引
我在同一目录中安装了两个 CMS。其中一个 CMS 允许将index.php 文件重命名为index2.php,而另一个则不允许。理想情况下,我想在 .htaccess 文件中设置一个条件规则:
- 使用 index.php 作为默认 DirectoryIndex
- 如果存在 404 错误,则将 DirectoryIndex 设置为 index2.php
有谁知道这是否/如何可能?
I have installed two CMSs in the same directory. One of the CMSs allows the index.php file to be renamed to index2.php, the other one does not. Ideally I'd like to set up a conditional rule in the .htaccess file which:
- Uses index.php as the default DirectoryIndex
- If there is a 404 error then set the DirectoryIndex to index2.php
Does anyone know if/how this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(404 = 文件未找到),因此您实际上正在寻找一种允许浏览可能的索引文件列表的方法)
将以下行添加到
.htaccess
文件中:当
index.php
存在时,将使用它。否则,使用index2.php
。当
index.php
和index2.php
存在时,使用index.php
,因为它首先出现。另请参阅: Apache 文档 > DirectoryIndex 指令。
(404 = File Not Found), so you're actually looking for a method which allows going through a list of possible index files)
Add the following line to your
.htaccess
file:When
index.php
exists, it's used. Otherwise,index2.php
is used.When
index.php
andindex2.php
exist,index.php
is used, because it appeared first.See also: Apache Docs > DirectoryIndex directive.