Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change 
notification.

The "RewriteLog" page has been changed by jmcg:
http://wiki.apache.org/httpd/RewriteLog

New page:
This here describes a recipie for creating a RewriteLog that is actually 
readable. It is based on Rich Bowen's presentation 
[[http://people.apache.org/~rbowen/presentations/Apache_Nuts_Bolts_files/|Apache
 Nuts and Bolts]]

Config:
{{{
RewriteLogLevel 9
RewriteLog "||/usr/local/rewrite_log_pipe"
}}}
Like in a usual setup, we set `RewriteLogLevel` high enough to be verbose 
enough. However, instead of logging to a file, we will pipe the log through a 
program.

This program will be a short and simple Perl script:

{{{#!perl
#!/usr/bin/env perl

$|++
open (F, ">>/tmp/rewrite.log");
select F;

while (<>) {
    s/^.*(\(\d\).*)/$1/;
    print;
}
}}}

This program opens the file `/tmp/rewrite.log`, looks for anything in the input 
that looks like '''(1)''' or '''(2)''' and drops everything before that.

Before:

{{{
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f7ef8/initial] (2) [perdir 
/srv/www/vhosts/hc-profi/] rewrite 'favicon.ico' -> '/index.php'
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f7ef8/initial] (2) [perdir 
/srv/www/vhosts/hc-profi/] trying to replace prefix /srv/www/vhosts/hc-profi/ 
with /
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f7ef8/initial] (1) [perdir 
/srv/www/vhosts/hc-profi/] internal redirect with /index.php [INTERNAL REDIRECT]
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f60a8/initial/redir#1] (2) init 
rewrite engine with requested uri /index.php
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f60a8/initial/redir#1] (1) pass 
through /index.php
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f60a8/initial/redir#1] (3) [perdir 
/srv/www/vhosts/hc-profi/] strip per-dir prefix: 
/srv/www/vhosts/hc-profi/index.php -> index.php
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f60a8/initial/redir#1] (3) [perdir 
/srv/www/vhosts/hc-profi/] applying pattern '^test_.*$' to uri 'index.php'
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f60a8/initial/redir#1] (3) [perdir 
/srv/www/vhosts/hc-profi/] strip per-dir prefix: 
/srv/www/vhosts/hc-profi/index.php -> index.php
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f60a8/initial/redir#1] (3) [perdir 
/srv/www/vhosts/hc-profi/] applying pattern '^index\.php$' to uri 'index.php'
94.62.148.237 - - [22/May/2012:04:05:50 +0300] 
[94.62.148.237/sid#7f65cc4cbac0][rid#7f65cc7f60a8/initial/redir#1] (1) [perdir 
/srv/www/vhosts/hc-profi/] pass through /srv/www/vhosts/hc-profi/index.php
}}}

After:

{{{
(2) [perdir /srv/www/vhosts/hc-profi/] rewrite 'favicon.ico' -> '/index.php'
(2) [perdir /srv/www/vhosts/hc-profi/] trying to replace prefix 
/srv/www/vhosts/hc-profi/ with /
(1) [perdir /srv/www/vhosts/hc-profi/] internal redirect with /index.php 
[INTERNAL REDIRECT]
(2) init rewrite engine with requested uri /index.php
(1) pass through /index.php
(3) [perdir /srv/www/vhosts/hc-profi/] strip per-dir prefix: 
/srv/www/vhosts/hc-profi/index.php -> index.php
(3) [perdir /srv/www/vhosts/hc-profi/] applying pattern '^test_.*$' to uri 
'index.php'
(3) [perdir /srv/www/vhosts/hc-profi/] strip per-dir prefix: 
/srv/www/vhosts/hc-profi/index.php -> index.php
(3) [perdir /srv/www/vhosts/hc-profi/] applying pattern '^index\.php$' to uri 
'index.php'
(1) [perdir /srv/www/vhosts/hc-profi/] pass through 
/srv/www/vhosts/hc-profi/index.php
}}}

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscr...@httpd.apache.org
For additional commands, e-mail: docs-h...@httpd.apache.org

Reply via email to