Conditional Directory Index in Htaccess

This refers to the question in:

index directory in .htaccess

The answer says the following should work:

SetEnvIf Remote_Addr ^127\.0\.0\.0$ owner
<IfDefine owner>
    DirectoryIndex index.html
</IfDefine>
<IfDefine !owner>
    DirectoryIndex index.php
</IfDefine>

I'm not sure if this works, setting Env var deffinately does, but no matter which IP I visit from DirectoryIndex, always index.php

Is something wrong with the conditional, or should I use something else?

Thanks in advance

+3
source share
2 answers

I ended up using the following to achieve what I wanted

DirectoryIndex index.html

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

Thank!

+1
source

<IfDefine>; , httpd , . mod_rewrite %{ENV:variable} RewriteCond .

0

Source: https://habr.com/ru/post/1733521/


All Articles