isapi 重写调试或测试工具
想知道是否有人知道或有调试一组 isapi 重写规则的经验?
我有一套相当大的规则,因此手动检查它们并不容易。所以我想知道是否有任何测试工具可用于放入规则并传递 URL,并查看匹配的规则以及生成的 URL 是什么?
或者如果失败了,某种高级日志记录可能会指导我发现问题可能出在哪里。
任何帮助将不胜感激,因为我的大脑快要融化了!
干杯
Was wondering if anyone was aware of, or had experience with, debugging a set of isapi rewrite rules?
I have a pretty large set of rules and so it is not easy to manually go through them. So i was wondering if there are any test harnesses available for putting in your rules and passing in a URL, and seeing what rule/s is/are matched and what the resultant URL is?
Or failing that, some kind of advanced logging which might guide me as to where my issues might lie.
Any help would be much appreciated as my brain is about to melt!
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经使用 isapi_rewrite 的调试日志记录完成了此操作。它效果很好,但对你的大脑融化没有帮助。一个真正的调试器会很好。
我假设您使用的是 isapi_rewrite v3。
日志记录由主 httpd.conf 文件控制。使用“管理器”应用程序编辑此文件,默认安装在“开始”->“节目->螺旋 -> ISAPI_Rewrite 3 -> ISAPI_Rewrite Manager
或者,您可以在 C:\Program Files\Helicon\ISAPI_Rewrite 3\httpd.conf(或等效的 Windows 安装目录)中手动编辑它。我相信它是隐藏的,所以很多人需要显示隐藏的文件。
这是我放入此文件中的注释,以便我记住这些设置。根据需要注释行的输入和输出。
RewriteLogLevel
是打开和关闭日志记录的设置。我一般使用0或9。出于好奇,我尝试过其他设置,但不知道具体情况。一般来说,如果我在追寻一个问题,我就想要这一切。RewriteLog 会指定一个备用日志文件,但我只是保留它未指定,它会写入 C:\Program Files\Helicon\ISAPI_Rewrite 3\ (或等效的 Windows 安装目录)中的
Rewrite.log
(我很少(从不?)使用 LogLevel;我只是将其保留在那里,注释掉,以提醒自己我不使用它。)
通过删除前导的
#
取消注释该行,然后保存它。 (在编辑器中,单击左上角的“应用”,或按 ctrl-s;然后在主对话框中再次应用。您可以将主对话框保持打开状态,以便再次快速将其注释掉。)Rewrite.log 文件将开始快速填满。这实际上只适用于开发系统,您的请求是唯一的。如果您正在进行生产,请打开它,点击页面,然后快速关闭它。日志文件具有 IP 地址,可以帮助查找您的规则。
您将看到的是初始请求通过所有规则,直到匹配为止。然后你会看到
[INTERNAL REDIRECT]
,这意味着它已经完成了规则的重写(这有点用词不当,愚弄了我一段时间 - 它只是意味着从我们的角度来看它正在重写,而不是“明确地”强制重定向”以进行实际的 Web 重定向)。以下是我对此问题的回答中的日志文件示例:
如何在 ISAPI_Rewrite 中重定向页面
将 /cnvrt 重定向到 /convert,然后将 /convert 重写为 /convert.aspx
您可以看到第一个与重定向匹配的块并执行此操作。然后第二个块是/convert url 匹配并重写为convert.aspx。如果没有匹配,那就不符合所有规则。您可以在第三个块中看到这一点,我的浏览器在其中寻找 favicon.ico,但没有找到。
这些日志也让人大开眼界,了解每个请求经过的程度 - 每个图像、样式表等都通过了所有规则。我尝试使用“快捷方式”规则来捕获 /img、/images、*.css、*.js,然后退出而不更改任何内容。您可以在下面看到这些尝试进行匹配。
最后一点:完成后,日志记录已关闭,请务必打开、清空并保存 Rewrite.log,不要删除 Rewrite.log 有很多Helicon 论坛上有关重新创建文件的权限问题的帖子。显然 isapi_rewrite 可以安装它并编辑它,但重新创建它可能会遇到麻烦。
I've done this with isapi_rewrite's debug logging. It works well, but it won't help with your brain melting. A true debugger would be nice.
I'll assume you're using isapi_rewrite v3.
The logging is controlled in the main httpd.conf file. Edit this file with their "Manager" app, default installation at Start -> Programs -> Helicon -> ISAPI_Rewrite 3 -> ISAPI_Rewrite Manager
Alternatively, you can edit it manually in C:\Program Files\Helicon\ISAPI_Rewrite 3\httpd.conf (or equivalent windows installation directory). I believe it is hidden, so you many need to show hidden files.
Here are my comments I put into this file, so I remember the settings. Comment the line in and out as needed.
The
RewriteLogLevel
is the setting that turns logging on and off. I generally use 0 or 9. I have tried other settings out of curiosity, but don't know the specifics. Generally I want it all if I'm chasing a problem.RewriteLog would specify an alternative log file, but I just leave it unspecified, and it writes to
Rewrite.log
in C:\Program Files\Helicon\ISAPI_Rewrite 3\ (or equivalent windows installation directory)(I have rarely (never?) used LogLevel; I just keep it there, commented-out, to remind myself I don't use it.)
Uncomment the line by removing the leading
#
, and saving it. (In their editor, click Apply in the upper left, or ctrl-s; then Apply again in the main dialog. You can leave the main dialog open to quickly comment it out again.)The Rewrite.log file will start filling up fast. This is really only practical on a development system, where your requests are the only ones. If you are on production, turn it on, hit the page, and turn it off quickly. The log files have IP addresses which can help locate your rules.
What you'll see is the initial request passing through all the rules, until it matches. Then you'll see
[INTERNAL REDIRECT]
which means it's done rewriting the rules (that's a bit of a misnomer that fooled me for a while - it just means it's rewriting from our view, vs the "explicitly forcing redirect" for an actual web redirect).Here is a log file example from my answer to this question:
How to redirect a page in ISAPI_Rewrite
This redirects /cnvrt to /convert, then rewrites /convert to /convert.aspx
You can see the first block matching the redirect and doing it. Then the second block is the /convert url matching and getting rewritten to convert.aspx. If there's no match, it just falls through all the rules. You can see this in the third block, where my browser went looking for favicon.ico, which it didn't find.
These logs are also an eye-opener for how much every request goes through - every image, stylesheet, etc. get put through all the rules. I played around with "shortcut" rules to catch /img, /images, *.css, *.js, and just exit without changing anything. You can see these trying to get matched below.
A final note: When done, and the logging is turned off, be sure to just open, empty and save Rewrite.log, DO NOT DELETE Rewrite.log There are many posts on the Helicon forums about permission troubles recreating the file. Apparently isapi_rewrite can install it and edit it, but can have troubles recreating it.
如果您可以在服务器或开发计算机上安装 Helicon Ape 而不是 ISAPI_Rewrite,那么您可以使用 Ape 产品附带的更方便的调试器。文档 mod_developer 和文章 mod_developer 。 com/articles/mod_developer-in-action/" rel="nofollow">跟踪 HTTP 流量和 IIS 配置
Helicon Ape 在 RewriteRule 语法方面与 ISAPI_Rewrite 3 兼容,因此您可以使用它来开发规则。
If you can install Helicon Ape instead of ISAPI_Rewrite on either server or development machine, then you con use more convenient debugger that comes with Ape product. Documentation mod_developer and article Trace HTTP traffic and IIS configuration
Helicon Ape is compatible with ISAPI_Rewrite 3 when it comes to RewriteRule syntax, so you can use it to develop rules.