You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@httpd.apache.org by Apache Wiki <wi...@apache.org> on 2017/12/14 15:20:14 UTC

[Httpd Wiki] Update of "RewriteLog" by thumbs

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 thumbs:
https://wiki.apache.org/httpd/RewriteLog?action=diff&rev1=5&rev2=6

Comment:
Removed older recipe as per Rich, and the broken link

  
  [[http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteloglevel|RewriteLogLevel]] 5
  
- = Recipes =
- 
- Here is a recipe for creating a rewrite log 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:
- {{{
- RewriteLog "||/usr/local/rewrite_log_pipe"
- }}}
- 
- Instead of logging to a file, the output will be piped through a script:
- 
- {{{#!perl
- #!/usr/bin/env perl
- 
- $|++
- open (F, ">>/tmp/rewrite.log");
- select F;
- 
- while (<>) {
-     s/^.*(\(\d\).*)/$1/;
-     print;
- }
- }}}
- 
- This script 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
- }}}
- 
- In this example, 'favicon.ico' is rewritten to /index.php, then the '^test_.*$' pattern is applied to the sub-request.
- 
- Lastly, the same sub-request has the '^index\.php$' pattern applied to. In this case, the result was a non-match, and the rule is skipped.
- 

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