php - Htaccess 中的条件目录索引

标签 php .htaccess directoryindex ifdefine

这与以下问题有关:

conditional DirectoryIndex in .htaccess

答案指出以下应该有效:

SetEnvIf Remote_Addr ^127\.0\.0\.0$ owner
<IfDefine owner>
    DirectoryIndex index.html
</IfDefine>
<IfDefine !owner>
    DirectoryIndex index.php
</IfDefine>

我不确定这是否有效,Env var 的设置确实有效,但无论我从哪个 IP 访问 DirectoryIndex 的站点始终是 index.php

条件语句有问题还是我应该使用其他东西?

提前致谢

最佳答案

我最终使用以下方法来实现我想要的

DirectoryIndex index.html

RewriteCond %{REMOTE_ADDR} ^my\.ip\.000\.000$
RewriteRule ^index.html$ index.php

谢谢!

关于php - Htaccess 中的条件目录索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2296477/

相关文章:

apache2 - 带有通配符 VirtualDocumentRoot 的 VirtualHost

php - 如何通过 PHP 和 mysql 正确转义字符串

.htaccess - htaccess 将目录名称重定向到参数

apache - .htaccess重定向到子域

apache - .htaccess 防止在浏览器中浏览子目录和更新 URL

php - MySQL单个查询计算多个日期范围内的行数

php - 抽象类与接口(interface)

php - 用于 php 安装的 Gmagick 扩展——如何安装以及在何处安装?

apache - 根据 .htaccess 中的域/子域更改 DirectoryIndex