i'm looking for the best way (fastest) so that my domain.com points directly at my /csp directory. What instruction in a main.c file, present in the headlers directory I guess, would you advise ?
Asked
Active
Viewed 230 times
0
-
What do you mean points directly? Are you talking about pretty URL (Without '?') – Richard Heath Feb 27 '13 at 15:29
1 Answers
0
If your goal is to have http://domain.com/
execute a script
rather than load a static page then use an URI rewrite:
int main(int argc, char *argv[])
{
const long state = (long)argv[0];
if(state == HDL_AFTER_READ)
{
xbuf_t *read_xbuf = (xbuf_t*)get_env(argv, READ_XBUF);
xbuf_replfrto(read_xbuf, read_xbuf->ptr, read_xbuf->ptr + 16, "/index.html", "/?index_1.c");
// Note: you may have to look for the ending double-CRLF to check
// if there are other pipelined requests to rewrite
}
return 255; // execute next connection step
}
The name "/?index_1.c"
is designed to use the same length as "/index.html"
to avoid a memmove() during the rewrite (having the same length allows for an in-place rewrite).

Gil
- 3,279
- 1
- 15
- 25
-
Your solution is working only in the case where the url entered is "domaine.com/index.html". If we just enter "domain.com", then the index_1 page won't be charged ! Wouldn't that be more interesting to use the xbuf_repl() function instead of xbuf_replfrto() ? (by using for example xbuf_repl(read_xbuf, "/", "/?") in order to avoir writing "?" each time) Thanks for all ;) – John S Mar 02 '13 at 02:06