Mobile app version of vmapp.org
Login or Join
Kevin317

: 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

@Kevin317

Posted in: #Apache2 #Htaccess #HttpHeaders

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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme