[英]Conditional Directory Index In Htaccess
这与以下问题有关:
答案说明以下内容应该有效:
SetEnvIf Remote_Addr ^127\.0\.0\.0$ owner
<IfDefine owner>
DirectoryIndex index.html
</IfDefine>
<IfDefine !owner>
DirectoryIndex index.php
</IfDefine>
我不确定这是否有效,Env var的设置确实如此,但无论我从DirectoryIndex访问该站点的IP总是index.php
条件有问题还是我应该使用其他东西?
提前致谢
我最终使用以下内容来实现我想要的
DirectoryIndex index.html
RewriteCond %{REMOTE_ADDR} ^my\.ip\.000\.000$
RewriteRule ^index.html$ index.php
谢谢!
你误解了<IfDefine>
的目的; 它检查在命令行传递给httpd
定义,而不是环境变量。 如果要测试环境变量,请在RewriteCond
使用mod_rewrite
的%{ENV:variable}
查找。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.