On Mon 03 Dec 2007, John ORourke wrote:
> I have some apps where users want to add extra domains and I'd like to
> do it on the fly if possible - in other words, modify the ServerAlias
> list from within mod_perl.  Does anyone have any tips/pointers/archives?

You mean you need a PerlTranslationHandler plus maybe a 
PerlMapToStorageHandler that inspect $r->hostname and add some configurations 
depending on it? Maybe Apache2::Translation can help.

Otherwise you can only edit the config file and restart apache.

Adding or modifying a ServerAlias at runtime is not possible in Perl. Even a 
PerlPostReadRequestHandler is run after the request is assigned to a vhost, 
see server/protocol.c:

    /* Get the request... */
    if (!read_request_line(r, tmp_bb)) {
        ...
        ap_get_mime_headers_core(r, tmp_bb);
    /* update what we think the virtual host is based on the headers we've
     * now read. may update status.
     */
    ap_update_vhost_from_headers(r);
    ...
    if ((access_status = ap_run_post_read_request(r))) {
    ...

read_request_line reads the GET/HEAD/POST/... line, ap_get_mime_headers_core 
reads the http headers and ap_update_vhost_from_headers switches to a name 
based vhost. Only after that the post read request phase is run. So you can't 
interfere before the request is assigned to the vhost.

Torsten

Reply via email to