Is it possible, to get a list of all handlers from apache? With setHandler it is possible to create handlers.
One possible usage would be to add a handler for a specific file extension (addHandler). Knowing all the possible handlers and their identifier would ease the process of matching them to a file extension (or in case of URL handlers creating a list of possible URLs).
The handlers must be managed in apache core in some kind of list - how is it possible to get this list out?
Apache does not expose a list of configured handlers. Not using
apachectl
, not with anything else.The best method that I could find to get a list of configured handlers is to simply grep the Apache configuration folder for
Handler
to catch allAddHandler
andSetHandler
declarations.For Debian-based (Ubuntu) hosts
For Redhat-based (Fedora, CentOS) hosts
Note that not all handlers found are in fact registered! Search in
mods-enabled
(Debian) and disregard lines starting with#
to narrow down only the registered handlers.As suggested by Jenny in the comments, commented lines can be removed by filtering the output with
grep -Pv '^[^ ]*:\s*#'
. Here is the final command for Debian-based machines:And for Redhat-based machines:
In the comments user gogoud provides an additional way to strip out commented handlers, thus returning only registered handlers:
This is isn't quite what you want, but if you enable the
server-info
handler in your config, the output will tell you which modules have handlers and which don't, like this:This was with Apache 2.2, so perhaps later versions will give you more useful output.