Apache .htaccess中的条件目录索引

Apache .htaccess中的条件目录索引,apache,.htaccess,conditional,Apache,.htaccess,Conditional,是否可以基于IP将.htaccess文件中的DirectoryIndex值设置为有条件的,以便-例如-我的IP将DirectoryIndex视为index.html,其他人将DirectoryIndex视为index.php 是否有一个解决方案,而不是mod_rewrite?据我所知,DirectoryIndex没有条件。您可以使用类似以下的mod_rewrite指令来模拟: RewriteCond %{REMOTE_ADDR} your_ip RewriteCond -d RewriteRul

是否可以基于IP将
.htaccess
文件中的DirectoryIndex值设置为有条件的,以便-例如-我的IP将
DirectoryIndex
视为index.html,其他人将
DirectoryIndex
视为index.php


是否有一个解决方案,而不是
mod_rewrite

据我所知,DirectoryIndex没有条件。您可以使用类似以下的mod_rewrite指令来模拟:

RewriteCond %{REMOTE_ADDR} your_ip
RewriteCond -d
RewriteRule (.*)/$ $1/index.html
如果您想将站点的其他访问者排除在index.html之外,那么也可以使用

RewriteCond %{REMOTE_ADDR} !your_ip
RewriteRule (.*)/index.html$ $1/index.php

使用提供的信息,我相信以下是您需要的:

RewriteCond %{REMOTE_ADDR} ^your_ip$
RewriteRule (.*)/$ $1/index.php

RewriteCond %{REMOTE_ADDR} !^your_ip$
RewriteRule index.php$ index.html
这样,只有您的IP可以看到index.php,其他所有人都可以看到index.html

或者可能:

DirectoryIndex index.html

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

是的,如果不可能的话,那将是我的退路。如果没有其他人有其他解决方案,我会接受。这对我来说很有效,但我如何添加多ip?DirectoryIndex.html RewriteCond%{REMOTE\u ADDR}^your\.ip\.000\.000$RewriteRule^index.html$index.php谢谢