conditional DirectoryIndex in .htaccess

前端 未结 2 387
暖寄归人
暖寄归人 2021-01-20 21:43

Is it possible to make the DirectoryIndex value in a .htaccess file conditional based on IP, so that - for example - my IP see\'s DirectoryIndex as

2条回答
  •  独厮守ぢ
    2021-01-20 22:09

    Using the provided information I beleive the following is what you need:

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

    So that only your IP can see index.php and everybody else will see index.html

    or possibly:

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

提交回复
热议问题