如何调试 Apache mod_rewrite [英] How to debug Apache mod_rewrite

查看:25
本文介绍了如何调试 Apache mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 mod_rewrite 时遇到两个主要问题:

I have two main problems with mod_rewrite:

  1. 当我的规则无效时,没有报告任何有意义的错误

  1. There is no meaningful error reported when I have an invalid rule

为了可靠地测试每个修改,我必须清除 Google Chrome 的缓存.这不是火箭科学,但我必须按 Ctrl + Shift + Delete,单击 OK,然后关闭窗口,然后重新加载.

To reliably test each modification, I have to erase Google Chrome's cache. This isn't rocket science, but I have to hit Ctrl + Shift + Delete, click OK, and close the window, and reload.

我想看看是否有任何大师愿意分享他们有效管理 mod_rewrite 代码的秘诀.

I'd like to see if any of the gurus are willing to share their secrets to efficiently managing mod_rewrite code.

推荐答案

一个技巧是打开重写日志.要打开它,请在您的 Apache HTTP Server 主配置或当前虚拟主机文件中尝试这一行(.htaccess 中的不是):

One trick is to turn on the rewrite log. To turn it on, try this line in your Apache HTTP Server main configuration or current virtual host file (not in .htaccess):

LogLevel alert rewrite:trace6

在 Apache httpd 2.4 mod_rewrite 之前,这样的 per-模块日志记录配置尚不存在.相反,您可以使用以下日志记录设置:

Before Apache httpd 2.4 mod_rewrite, such a per-module logging configuration did not exist yet. Instead you could use the following logging settings:

RewriteEngine On
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3

这篇关于如何调试 Apache mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆