Is it possible to conditionally call AddHandler in the .htaccess under Apache (2.x)?My present situation requires that a certain AddHandler is needed by one production server but that one breaks the development server. This requires to have 2 versions of .htaccess which is pain. So, instead I would like to wrap one AddHandler within a conditional. Something of this sort:IF IP=='1.2.3.4' THENAddHandler type/foo .extENDIFThe problem is new but out of my control for now. I know this is far from ideal and the servers used to match 100% as they should but temporarily they cannot.
Conditional AddHandler Directive
apache;htaccess;handler
Use mod_rewrite and the H= flag.  In .htaccess, use a - as the substitution if you set H= in a flag.  You can then do your IP checks in a RewriteCond.Here's some (untested!) code to accomplish this:# Standard preamble for using mod_rewrite in a root .htaccess file:RewriteEngine OnRewriteBase /Options +FollowSymLinks# Handle .ext files as type/foo if the server address is 1.2.3.4:RewriteCond %{SERVER_ADDR} =1.2.3.4RewriteCond %{SCRIPT_FILENAME} \.ext$RewriteRule ^ - [H=type/foo]