Reputation: 2044
I would like to have a conditional setting for a specific domian in my .htaccess file. My use case is I have dev (example.dev) and live (example.com). The htaccess file is in my git repo but I have some settings in .htaccess that should only apply to the live site. Ideally I would like to have a conditional setting like the pseudo code below:
<sometag domain=my_prod_domain example.com>
#code specific to only the live domain here
</sometag>
Upvotes: 1
Views: 855
Reputation: 4461
Do you have access to the main configuration files?
If yes, then you could specify a different configuration file for your different hosts using
AccessFileName .public.htaccess
and
AccessFileName .dev.htaccess
And then you could work with the Include directive to load configurations common to both.
Include .common.htaccess
Another idea would be to try to work with the If-Directives, but it all really depends on your setup and level of access to the configurations: http://httpd.apache.org/docs/2.4/mod/core.html#if
Edit:
Okay I think with IfDefine you can do something even more along the lines with you original though:
Start your dev. Server with httpd -DDevServer
and have on your statements like this:
<IfDefine DevServer>
#Config specific for your dev. server
</IfDefine>
<IfDefine !DevServer>
#Config specific for your live server.
<IfDefine>
For this solution you do not need even root access on your live-server.
Upvotes: 3