[英]conditional DirectoryIndex based on IP address, using .htaccess
[英]conditional DirectoryIndex in .htaccess
是否有可能使.htaccess
文件中的DirectoryIndex值基于IP有条件,因此 - 例如 - 我的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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.