pp wrote:
> > I recompiled mod_midgard with this patch, but I do not see
> > any improvments.... :(
>
> I mean MidgardFlavorFiles is On for that vitual host
> and all users dir with '~' are displayed correctly
> except that one host with rewrite rule.
> I tried to load rewrite module after midgard and php module
> but it looks like then apache "only seems to be working"
> with no specific logs......
mod_rewrite does internal subrequests, and Midgard declines those. So I
can see why this wouldn't work. The attached patch should only decline
subrequests that are started by Midgard itself, so mod_rewrite ought to
work with this. If this doesn't work, I don't really know what will.
Emile
--- mod_midgard.c-org Sun Mar 24 09:21:46 2002
+++ mod_midgard.c Wed Jul 24 21:08:14 2002
@@ -52,6 +52,8 @@
#define LIBEXEC_DIR "libexec"
#endif
+#define MIDGARD_SUBREQUEST_NOTE "MidgardSubrequest"
+
int midgard_authenticate(midgard_request_config * rcfg);
int mgd_get_basic_auth_pw(request_rec * r, const char **usr, const char **pw);
@@ -69,6 +71,8 @@
static int persistent_connect = TRUE;
+static int favor_files = FALSE;
+
module midgard_module;
static const char *verify_user(midgard_request_config * rcfg)
@@ -541,6 +545,13 @@
return NULL;
}
+static const char *midgard_favor_files_cmd(cmd_parms * cmd, void *cfg, int flag)
+{
+ favor_files = flag;
+
+ return NULL;
+}
+
static const char *midgard_persistent_cmd(cmd_parms * cmd, void *cfg, int flag)
{
persistent_connect = flag;
@@ -1162,6 +1173,7 @@
}
/* determine translated filename + handler by subrequest */
+ ap_table_set(r->notes, MIDGARD_SUBREQUEST_NOTE, MIDGARD_SUBREQUEST_NOTE);
if ((subreq = ap_sub_req_lookup_uri(r->uri, r)) == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r,
"Midgard: filetemplate request subrequest failed");
@@ -1270,6 +1282,11 @@
}
}
+/*
+**
+** stat() for only the prefix of a path
+**
+*/
static int midgard_translate_handler(request_rec * r)
{
midgard_server_config *scfg;
@@ -1278,14 +1295,18 @@
const char *uri, *parser;
struct _ftstatus ftstatus;
+ request_rec *subreq;
+
#if MIDGARD_PHP_REQUEST_CONFIG_BUG_WORKAROUND
mgd_php_bug_workaround_set_rcfg_dcfg(NULL, NULL);
#endif
- /* we don't do subrequests */
- if (r->main != NULL)
+ /* we don't do subrequests in which we were previously involved */
+ if (r->main != NULL
+ && ap_table_get(r->notes, MIDGARD_SUBREQUEST_NOTE) != NULL)
return DECLINED;
+
/* midgard-lib was recompiled with a different sitegroup setting, bail */
if (sitegroup_lib_mismatch)
return DECLINED;
@@ -1302,6 +1323,30 @@
dcfg->parser : default_parser,
ap_get_server_name(r), ap_get_server_port(r), r->uri);
+ /*[eeh] determine translated filename + handler by subrequest
+ * _unless_ we're requesting the root page. The root page will
+ * generally resolve to the docroot, and that'll allways
+ * match in favor of the midgard request => root page
+ * unreachable. Another way would be to check for
+ * directories, but given the fact that most people
+ * (including me) like and use directory => index.html
+ * mapping, I'd rather use this hack.
+ */
+ if (favor_files && r->uri[0] != '\0' && (r->uri[0] != '/' || r->uri[1] != '\0')) {
+ ap_table_set(r->notes, MIDGARD_SUBREQUEST_NOTE, MIDGARD_SUBREQUEST_NOTE);
+ if ((subreq = ap_sub_req_lookup_uri(r->uri, r)) != NULL &&
+subreq->finfo.st_mode != 0) {
+ if (subreq->filename != NULL && subreq->content_type != NULL) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r,
+ "Midgard: file %s exists [%s] (%d), not serving from
+database",
+ subreq->filename, subreq->content_type, subreq->status);
+ ap_destroy_sub_req(subreq);
+ return DECLINED;
+ }
+
+ ap_destroy_sub_req(subreq);
+ }
+ }
+
/* Check that the Midgard database is available */
scfg = (midgard_server_config *)
ap_get_module_config(r->server->module_config, &midgard_module);
@@ -1532,6 +1577,8 @@
"Name of the Midgard database, username and password from which to
authenticate"},
{"MidgardEngine", midgard_engine_cmd, NULL, MGD_CONF, FLAG,
"On or Off to enable or disable (default) the Midgard engine"},
+ {"MidgardFavorFiles", midgard_favor_files_cmd, NULL, MGD_CONF, FLAG,
+ "On or Off to favor files or midgard urls when both match"},
{"MidgardPersistentConnect", midgard_persistent_cmd, NULL, MGD_CONF, FLAG,
"On or Off to enable (default) or disable persistent database connections"},
{"MidgardRootfile", midgard_rootfile_cmd, NULL, MGD_CONF, TAKE1,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]