
這牽涉到以下問題:
https://stackoverflow.com/questions/1599717/conditional-directoryindex-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
條件有問題還是我應該使用其他東西?
先致謝
答案1
我最終使用以下內容來實現我想要的
RewriteCond %{REMOTE_ADDR} ^111\.111\.111\.111$
RewriteRule (.*)/$ $1/index.php
RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111$
RewriteRule index.php$ index.html
謝謝!