: Use different .htaccess file based on set header from browser I want to have the ability to test .htaccess rules before saving them to the main .htaccess file. Is it possible to set a specific
I want to have the ability to test .htaccess rules before saving them to the main .htaccess file.
Is it possible to set a specific request header and have Apache use a set of rules from a different .htaccess file.
More posts by @Kevin317
1 Comments
Sorted by latest first Latest Oldest Best
This may be possible with Apache 2.4's new features which includes <If>, <ElseIf> and <Else> directives.
httpd.apache.org/docs/2.4/mod/core.html#if
Possible example:
AccessFileName .htaccess
<If "$req{Host} != 'test.mydomain.com'">
AccessFileName .htaccess_test
</If>
For older versions I am not aware of any such options. Perhaps using SetEnvIf would work.
httpd.apache.org/docs/2.2/mod/mod_setenvif.html
SetEnvIf Remote_Host "^test.mydomain.com$" htaccess_file_name=.htaccess_test
SetEnvIf Remote_Host "^www.mydomain.com$" htaccess_file_name=.htaccess
AccessFileName htaccess_file_name
I haven't tried this so I can't say that it will actually work at all but it's worth a shot.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.