在旧的Apache的httpd.conf里面是有这样的参数的:
1
|
RewriteLog "/myfolder/mylogfile.log"
|
2
|
RewriteLogLevel 3
|
但是在新版本的Apache中,已经取消了RewriteLog这个参数,如果你加上这个参数只会使你的Apache无法启动!新版本的Apache已经把Rewrite模块的日志也写到了Apache的error.log中,只需要我们制定一下输出的log的级别和trace的深度就好了,例如
1
|
LogLevel alert rewrite:trace3
|
LogLevel的级别和深度选择如下表:
Level | Description | Example |
---|---|---|
emerg
|
Emergencies – system is unusable. | “Child cannot open lock file. Exiting” |
alert
|
Action must be taken immediately. | “getpwuid: couldn’t determine user name from uid” |
crit
|
Critical Conditions. | “socket: Failed to get a socket, exiting child” |
error
|
Error conditions. | “Premature end of script headers” |
warn
|
Warning conditions. | “child process 1234 did not exit, sending another SIGHUP” |
notice
|
Normal but significant condition. | “httpd: caught SIGBUS, attempting to dump core in …” |
info
|
Informational. | “Server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers)…” |
debug
|
Debug-level messages | “Opening config file …” |
trace1
|
Trace messages | “proxy: FTP: control connection complete” |
trace2
|
Trace messages | “proxy: CONNECT: sending the CONNECT request to the remote proxy” |
trace3
|
Trace messages | “openssl: Handshake: start” |
trace4
|
Trace messages | “read from buffered SSL brigade, mode 0, 17 bytes” |
trace5
|
Trace messages | “map lookup FAILED: map=rewritemap key=keyname” |
trace6
|
Trace messages | “cache lookup FAILED, forcing new map lookup” |
trace7
|
Trace messages, dumping large amounts of data | “| 0000: 02 23 44 30 13 40 ac 34 df 3d bf 9a 19 49 39 15 |” |
trace8
|
Trace messages, dumping large amounts of data | “| 0000: 02 23 44 30 13 40 ac 34 df 3d bf 9a 19 49 39 15 |” |
因此我们假如需要调试某个虚拟主机的伪静态的话,我们可以在给虚拟主机的<VirtualHost>配置项或者.htaccess里面加入如下的一段配置:
1
|
<IfModule mod_rewrite.c>
|
2
|
LogLevel debug rewrite:trace3
|
3
|
</IfModule>
|
然后访问一下,error.log里面就会有具体的信息了,可以看到你提交的URL被映射到了哪个文件,进行有针对性的调整。
附官方说明文档:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#logging
再附一个.htaccess调试网址:http://martinmelin.se/rewrite-rule-tester/
转自:http://www.nigesb.com/debug-the-mod_rewrite-in-apache.html
转载请注明:Findever » 【转】调试Apache的rewrite规则方法