3

This relates to the question in:

conditional DirectoryIndex in .htaccess

The answer states that 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 am not sure this works, the setting of the Env var deffinately does, but no matter what IP I visit the site from the DirectoryIndex is always index.php

Is there something wrong with the conditional or should I be using something else?

Thanks in advance

Community
  • 1
  • 1
Lizard
  • 39,504
  • 36
  • 102
  • 164

2 Answers2

1

I have 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

Thanks!

Lizard
  • 39,504
  • 36
  • 102
  • 164
0

You're misunderstanding the purpose of <IfDefine>; it checks defines passed to httpd at the command line, not environment variables. Use mod_rewrite's %{ENV:variable} lookup in RewriteCond if you want to test environment variables.

Ignacio Vazquez-Abrams
  • 699,552
  • 132
  • 1,235
  • 1,283