how to debug nginx rewrite rule.

2 method

1.
error_log /srv/www/example.com/log/error.log debug;

2.
rewrite_log on;
error_log /srv/www/example.com/log/error.log notice;

if you want to check a variable’s value , you can direct use following script
rewrite ^ $var_you_want_check break;

then you can find something like following in error.log , the strings in RED , is the value of $var_you_want_check
2012/07/03 14:15:24 [notice] 25289#0: *30519 "^" matches "/2012/02/01/february-1-7-gnc-gold-card-weeks-gnc-com-and-drugstore-com-gnc-products-of-a-discount.html", client: 116.24.4.227, server: 6658.net, request: "GET /2012/02/01/february-1-7-gnc-gold-card-weeks-gnc-com-and-drugstore-com-gnc-products-of-a-discount.html HTTP/1.1", host: "6658.net", referrer: "http://6658.net/wp-content/cache/supercache/6658.net/2012/01/31/gnc-more-than-one-hundred-products-less-than-10-dollar-free-shipping.html/index.html"
2012/07/03 14:15:24 [notice] 25289#0: *30519 rewritten data: "/example.com/public_html/wp-content/cache/supercache/6658.net/2012/02/01/february-1-7-gnc-gold-card-weeks-gnc-com-and-drugstore-com-gnc-products-of-a-discount.htmlindex.html", args: "", client: 116.24.4.227, server: 6658.net, request: "GET /2012/02/01/february-1-7-gnc-gold-card-weeks-gnc-com-and-drugstore-com-gnc-products-of-a-discount.html HTTP/1.1", host: "6658.net", referrer: "http://6658.net/wp-content/cache/supercache/6658.net/2012/01/31/gnc-more-than-one-hundred-products-less-than-10-dollar-free-shipping.html/index.html"

发表评论

电子邮件地址不会被公开。 必填项已用*标注