Apache:在哪里检查重定向日志?


10

我有复杂的RewriteCondRewriteRule在一台机器。并且根据这些规则,某些请求将被重定向到另一台计算机。

那么,是否有任何Apache日志清楚地显示了重定向的过程?因为重定向以我意想不到的方式发生。

Answers:


9

对于初学者,这是您应该如何编写* .conf文件的方法:

  NameVirtualHost *:80
  <VirtualHost *:80 >
    ServerName gw.myserver.net
    DocumentRoot "C:\Program Files\MyCompany\myserver\Web"
    DirectoryIndex index.html index.php
    RewriteLog "logs\rewritelog.txt"
    RewriteLogLevel 3
    <Directory  "C:\Program Files\ MyCompany\ myserver\Web">
       AddDefaultCharset UTF-8
       Order Deny,Allow
       Allow from all

       RewriteEngine on
       RewriteBase /
       RewriteCond %{HTTP_HOST}   ^gw\. myserver\.net$
       RewriteRule !^(login|index.php)  http://pmmenu. myserver\.net%{REQUEST_URI}$1 [L,R=301]
       # we check if the .html version is here (caching)
       RewriteRule ^$ index.html [QSA]
       RewriteRule ^([^.]+)$ $1.html [QSA]
       RewriteCond %{REQUEST_FILENAME} !-f

       # no, so we redirect to our front web controller
       RewriteRule ^(.*)$ index.php [QSA,L]
    </Directory>
  </VirtualHost>

2
好的答案-尚未启动,请记住,生产服务器上的日志级别高于2会对性能产生重大影响。
09年

7
对于较新的Apache版本(至少2.4及更高版本),RewriteLog / RewriteLogLevel不再起作用。它已取代LogLevel指令:httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging
ronneseth


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.