重写自定义日志中的 URL
我在 http.conf
中定义了一个重写 URL,以将参数附加到请求 URL。在自定义日志输出中,我没有看到修改后的请求 URL。当我查看原因时,我在一个论坛中发现 mod_rewrite
仅影响通过 HTTP 调用的访问,不会影响服务器内部的文件操作。这是真的吗?有没有办法在 Apache 日志中仅记录修改后的重写 URL?非常感谢您的帮助。
我尝试访问的示例 URL 是 http://www.abc.com/pixel.gif?on=test
,在输出中我想要类似 /pixel.gif?type =修改&on=测试
。
RewriteCond %{HTTP_HOST} www\.abc\.com
RewriteRule ^/(.*)$ /$1?type=modified [QSA,L]
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
I have defined a rewrite URL in http.conf
to append a parameter to the request URL. In the Custom Log output I am not seeing the modified request URL. When I looked at the cause I found in one of the forums that mod_rewrite
only affects accesses invoked via HTTP and does not affect file operations inside the server. Is that true and is there any way to log only the modified rewrite URL in the Apache logs? Your help is much appreciated.
The sample URL I am trying to access is http://www.abc.com/pixel.gif?on=test
and in the output I want something like /pixel.gif?type=modified&on=test
.
RewriteCond %{HTTP_HOST} www\.abc\.com
RewriteRule ^/(.*)$ /$1?type=modified [QSA,L]
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您打开RewriteLog<,就有一种方法可以记录与重写相关的事情/a> 指令。
基本上,您可以将其添加到您的 .htaccess 文件(并且日志路径可能会有所不同):
但请注意,
RewriteLogLevel
确实会减慢您的开发或生产服务器的速度。您可能想使用更小的数字...而不是5
。当您检查完RewriteRule
后...您很可能想要注释掉(或删除)RewriteLog
/RewriteLogLevel
线。希望对您的调试有所帮助!
There is a way to log rewrite-related things if you turn on the RewriteLog directive.
Basically, you would be adding this to your .htaccess file (and the log path may vary):
But note, that
RewriteLogLevel
can really slow down your development or production server. You might want to use a smaller number... instead of5
. And when you are done checking yourRewriteRule
s... you will most likely want to comment out (or delete,) theRewriteLog
/RewriteLogLevel
lines.Hope that helps with your debugging!