*pathname* 'PATTERN'...::
- Matches if the entire path (relative as considered from the
- root directory being served) of the file under consideration
+ Matches if the entire path of the file under consideration
matches any of the 'PATTERNs'. A 'PATTERN' is an ordinary glob
pattern, except that slashes are not matched by wildcards. See
- *fnmatch*(3) for more information.
+ *fnmatch*(3) for more information. If a *pathname* rule is
+ specified in a `.htrc` file, the path will be examined as
+ relative to the directory containing the `.htrc` file, rather
+ than to the root directory being served.
*default*::
struct pattern *findmatch(char *file, int trydefault, int dir)
{
int i, o, c;
- char *bn;
+ char *bn, *ln;
struct config **cfs;
struct pattern *pat;
struct rule *rule;
bn = file;
cfs = getconfigs(file);
for(c = 0; cfs[c] != NULL; c++) {
+ if(cfs[c]->path == NULL) {
+ ln = file;
+ } else {
+ pl = strlen(cfs[c]->path);
+ if((strlen(file) > pl) && !strncmp(file, cfs[c]->path, pl) && (file[pl] == '/'))
+ ln = file + pl + 1;
+ else
+ ln = file; /* This should only happen in the base directory. */
+ }
for(pat = cfs[c]->patterns; pat != NULL; pat = pat->next) {
if(!dir && (pat->type == PT_DIR))
continue;
break;
} else if(rule->type == PAT_PATHNAME) {
for(o = 0; rule->patterns[o] != NULL; o++) {
- if(!fnmatch(rule->patterns[o], file, FNM_PATHNAME))
+ if(!fnmatch(rule->patterns[o], ln, FNM_PATHNAME))
break;
}
if(rule->patterns[o] == NULL)
if(!trydefault)
break;
} else if(rule->type == PAT_LOCAL) {
- if(cfs[c]->path == NULL)
- break;
- pl = strlen(cfs[c]->path);
- if(!((strlen(file) > pl) && !strncmp(file, cfs[c]->path, pl) && (file[pl] == '/') && !strchr(file + pl + 1, '/')))
+ if(strchr(ln, '/'))
break;
}
}