- nm = req->rest;
- path = sstrdup(".");
- p = nm;
- while(1) {
- if((p2 = strchr(p, '/')) == NULL) {
- } else {
- *(p2++) = 0;
- }
-
- if(!*p) {
- if(p2 == NULL) {
- if(stat(path, &sb)) {
- flog(LOG_WARNING, "failed to stat previously stated directory %s: %s", path, strerror(errno));
- simpleerror(fd, 500, "Internal Server Error", "The server encountered an unexpected condition.");
- goto fail;
+ cpath = sprintf2("%s/", path);
+ cfs = getconfigs(cpath);
+ for(i = 0; cfs[i] != NULL; i++) {
+ if(cfs[i]->index != NULL) {
+ for(o = 0; cfs[i]->index[o] != NULL; o++) {
+ inm = cfs[i]->index[o];
+ ipath = sprintf2("%s/%s", path, inm);
+ if(!stat(ipath, &sb) && S_ISREG(sb.st_mode)) {
+ handlefile(req, fd, ipath);
+ free(ipath);
+ goto out;
+ }
+ free(ipath);
+
+ if(!strchr(inm, '.') && ((ipath = findfile(path, inm, NULL)) != NULL)) {
+ handlefile(req, fd, ipath);
+ free(ipath);
+ goto out;