调试 mod_rewrite

发布于 2024-08-27 02:27:08 字数 246 浏览 2 评论 0原文

我正在使用 Apache 的 mod_rewrite 模块,想知道是否有一种不错的方法来输出一些调试信息?例如,文档列出了许多可用的变量:

%{HTTP_USER_AGENT}, %{HTTP_REFERER}, %{HTTP_COOKIE} ... etc

有没有一种方法可以输出这些变量只是为了看看我正在使用什么?我设置了 RewriteLog(级别 2)并一直在查看它,但如果能够看到变量的值那就太好了。

I'm playing around with Apache's mod_rewrite module, and want to know if there is a decent way to output some debugging information? For example, the documentation lists a number of variables available:

%{HTTP_USER_AGENT}, %{HTTP_REFERER}, %{HTTP_COOKIE} ... etc

Is there a way I could output these just to see what I'm working with? I set up the RewriteLog (Level 2) and have been looking at that, but it'd be nice to be able to see the value of the variables.

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

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

发布评论

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

评论(1

寄意 2024-09-03 02:27:08

HTTP_ 变量来自 HTTP 标头,因此您可以使用服务器端脚本打印它们,就像大多数其他变量一样。对于特殊变量,您可以在 RewriteCond 中捕获它们的值并将其附加到查询字符串中。

RewriteCond RF=%{REQUEST_FILENAME}&API=%{API_VERSION} (.*)
RewriteRule ... ...?%1 [QSA]

为了调试重写规则,我发现单独运行虚拟主机很有帮助为此目的。

The HTTP_ variables come from HTTP headers, so you can print them using server side scripting, as with most of the other variables. For special variables, you can capture their values in a RewriteCond and append that to the query string.

RewriteCond RF=%{REQUEST_FILENAME}&API=%{API_VERSION} (.*)
RewriteRule ... ...?%1 [QSA]

To debug rewrite rules, I've found it helpful to run a virtual host solely for this purpose.

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