0

我正在寻找最好的方法(最快),以便我的 domain.com 直接指向我的 /csp 目录。main.c 文件中的什么指令,我猜是在headlers 目录中,你会建议吗?

4

1 回答 1

0

如果您的目标是http://domain.com/执行script而不是加载静态页面,则使用 URI 重写:

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
}

该名称"/?index_1.c"旨在使用相同的长度,"/index.html"以避免在重写期间使用 memmove()(具有相同的长度允许就地重写)。

于 2013-02-27T16:36:09.887 回答