conditional DirectoryIndex in .htaccess

前端 未结 2 368
暖寄归人
暖寄归人 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:23

    As far as I know, there is no conditional for DirectoryIndex. You could simulate that with a mod_rewrite directive like this one:

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

    If you want to exclude other visitors of the site from viewing index.html then also use

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

提交回复
热议问题