在Apache 2.2上记录mod_rewrite [英] Logging mod_rewrite on Apache 2.2

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

问题描述

我正在尝试对在Centos 6.5上运行的Apache2.2.15上的mod_rewrite进行故障排除.我的httpd.conf文件如下:

I am trying to troubleshoot mod_rewrite on Apache2.2.15 operating on Centos 6.5. My httpd.conf file is as follows:

<VirtualHost *:80>
    ServerName somesite.com
    DocumentRoot /var/www/somesite/html
    <Directory "/var/www/somesite/html">
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteLog /var/log/httpd/rewrite.log
            RewriteLogLevel 3
        </IfModule>
    </Directory>
</VirtualHost>

在第1044行对应于RewriteLog /var/log/httpd/rewrite.log的情况下,我继续遇到以下错误.

I keep on getting the following error where line 1044 corresponds to RewriteLog /var/log/httpd/rewrite.log.

[root@devserver httpd]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: Syntax error on line 1044 of /etc/httpd/conf/httpd.conf:
RewriteLog not allowed here
                                                           [FAILED]
[root@devserver httpd]#

我可以将RewriteLog /var/log/httpd/rewrite.log添加到httpd.conf的主要部分(不是虚拟主机),但是虚拟主机不会记录任何内容.

I can add RewriteLog /var/log/httpd/rewrite.log to the main section (not virtual host) of httpd.conf, but nothing gets logged from the virtual host.

如何记录mod_rewrite事务?

How do I log mod_rewrite transactions?

推荐答案

请参见 http ://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

RewriteLog需要具有服务器配置或虚拟主机的上下文.尝试以下方法:

RewriteLog needs to have a context of server config or virtual host. Try this instead:

<VirtualHost *:80>
  <IfModule mod_rewrite.c>
    RewriteLog /var/log/httpd/rewrite.log
    RewriteLogLevel 3
  </IfModule>
  ServerName somesite.com
  DocumentRoot /var/www/somesite/html
  <Directory "/var/www/somesite/html">
      <IfModule mod_rewrite.c>
        RewriteEngine On
      </IfModule>
  </Directory>
</VirtualHost>

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

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