Use different .htaccess file based on set header from browser
Use different .htaccess file based on set header from browser -
Solution :
Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, apache2, http-headers, , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :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.
This may be possible with Apache 2.4's new features which includes <If>, <ElseIf> and <Else> directives.
http://httpd.apache.org/docs/2.4/mod/core.html#if
Possible example:
AccessFileName .htaccess
<If "$reqHost != 'test.mydomain.com'">
AccessFileName .htaccess_test
</If>
For older versions I am not aware of any such options. Perhaps using SetEnvIf would work.
http://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.
Comments
Post a Comment