无需 mod_rewrite 的 Apache URL 重写

发布于 2024-10-10 10:47:57 字数 402 浏览 0 评论 0原文

我正在将 IIS asapi 过滤器移植到 linux/apache,并且想知道采用它的最佳路径是什么。在 IIS 上,此 isapi 过滤器拦截请求,执行数据库查找以查找用户请求的文件,然后重写 URL 以直接提供该文件。

在 Apache 上执行此操作的最佳方法是什么? mod_rewrite 似乎没有插入用户代码来执行数据库查找的功能,因此我们无法使用它。我们不能使用 mod_isapi,因为我们的 DLL 是一个过滤器,而该模块不支持它。

现在,我认为最直接的方法是使用 mod_rewrite 代码作为指导来编写我们自己的 C 模块。如果可以的话我想避免这种情况。我也不想通过 perl/PHP/任何脚本为每个请求发出 HTTP 重定向,因为重定向会影响性能。

建议?我们可以使用 Apache 处理程序或过滤器来完成此任务吗?

I'm porting an IIS asapi filter over to linux/apache, and am wondering what the best path to take it. On IIS, this isapi filter intercepts the request, performs a database lookup to find the file the user is requesting, and then rewrites the URL to directly serve that file.

What is the best way to do this on Apache? mod_rewrite doesn't seem to have a facility to interject user code to perform a database lookup, so we can't use that. We can't use the mod_isapi since our DLL is a filter and the module doesn't support that.

Right now, I'm thinking the most straightforward way is to write our own C module, using the mod_rewrite code as a guide. I'd like to avoid that if I can. I also don't want to have to issue an HTTP redirect for each request via a perl/PHP/whatever script since performance will suffer with the redirect.

Suggestions? Can we use Apache handlers or filters to accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨小沫ゞ 2024-10-17 10:47:57

在 mod_rewrite 中,MapType“prg”就是为了做到这一点。它允许您使用任何可执行文件作为映射,您的程序所要做的就是读取字符串并输出查找值。

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

In mod_rewrite, The MapType "prg" is meant to do exactly this. It lets you use any executable file as your map, all your program has to do is read in strings and output the lookup value.

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文