调试 mod_rewrite
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP_ 变量来自 HTTP 标头,因此您可以使用服务器端脚本打印它们,就像大多数其他变量一样。对于特殊变量,您可以在 RewriteCond 中捕获它们的值并将其附加到查询字符串中。
为了调试重写规则,我发现单独运行虚拟主机很有帮助为此目的。
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.
To debug rewrite rules, I've found it helpful to run a virtual host solely for this purpose.