简体   繁体   English

在Apache 2.2上记录mod_rewrite

[英]Logging mod_rewrite on Apache 2.2

I am trying to troubleshoot mod_rewrite on Apache2.2.15 operating on Centos 6.5. 我正在尝试解决在Centos 6.5上运行的Apache2.2.15上的mod_rewrite问题。 My httpd.conf file is as follows: 我的httpd.conf文件如下:

<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>

I keep on getting the following error where line 1044 corresponds to RewriteLog /var/log/httpd/rewrite.log . 我继续得到以下错误,其中第1044行对应于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]#

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. 我可以将RewriteLog /var/log/httpd/rewrite.log添加到httpd.conf的主要部分(不是虚拟主机),但不会从虚拟主机中记录任何内容。

How do I log mod_rewrite transactions? 如何记录mod_rewrite事务?

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

RewriteLog needs to have a context of server config or virtual host. RewriteLog需要具有服务器配置或虚拟主机的上下文。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM