capache-modules

How to Restrict an Apache Module (Handler) to a Virtual Host (vhost)


I have an apache module which uses the ap_hook_post_read_request hook to perform an internal redirect when certain conditions are met. I would like to restrict this handler to a single virtual host but currently it fires on all virtual hosts (there are many). The httpd.conf configuration is limited to the LoadModule directive. I've tried using SetHandler handlername in the vhost and SetHandler None in the main config but the handler is still invoked on requests to other vhosts. The module also registers the ap_register_output_filter hook but the output filter does not perform any action other than removing itself and passing control onwards.


Solution

  • I created some custom config in the vhost. I look for this config in the module and return if it doesn't have the config, so this in effect allows me to restrict the module to a vhost.