Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides

FAQ
It is currently Wed May 24, 2017 1:10 pm


Tutorials applicable on more than one Unix/Linux OS and shell scripts: ssh / openssl / protocols.

Author Message
LaR3
  Post  Post subject: Debug Apache's mod_rewrite with RewriteLog and RewriteLogLevel directives  |  Posted: Thu Aug 27, 2009 5:14 am

Joined: Mon Aug 03, 2009 4:55 pm
Posts: 19

Offline
 

Debug Apache's mod_rewrite with RewriteLog and RewriteLogLevel directives

Rewriting URLs in Apache is a simple thing if you're skilled in RegEx (Regular Expressions). But there can be cases when URL rewriting doesn't work and you need to debug it.

Apache supports two directives that can come in handful: RewriteLog and RewriteLogLevel.

For best results, place these directives into your Virtual host configuration, not in httpd.conf (general Apache config file) so that you'll get information about rewritten URL's only in from the specific vhost.

Code:
    <VirtualHost *:80>
    DocumentRoot /www/domain.tld
    ServerName www.domain.tld
    RewriteLog "/var/log/www/domain.tld/rewrite.log"
    RewriteLogLevel 4
    </VirtualHost>


Quote:
RewriteLog
Syntax: RewriteLog file-path
Default: None
Context: server config, virtual host
Override: Not applicable
Status: Extension
Module: mod_rewrite.c
Compatibility: Apache 1.2

The RewriteLog directive sets the name of the file to which the server logs any rewriting actions it performs. If the name does not begin with a slash ('/') then it is assumed to be relative to the Server Root. The directive should occur only once per server config.
Note: To disable the logging of rewriting actions it is not recommended to set file-path to /dev/null, because although the rewriting engine does not then output to a logfile it still creates the logfile output internally. This will slow down the server with no advantage to the administrator! To disable logging either remove or comment out the RewriteLog directive or use RewriteLogLevel 0!
Security: See the Apache Security Tips document for details on why your security could be compromised if the directory where logfiles are stored is writable by anyone other than the user that starts the server.

Example:

RewriteLog "/usr/local/var/apache/logs/rewrite.log"


RewriteLogLevel
Syntax: RewriteLogLevel Level
Default: RewriteLogLevel 0
Context: server config, virtual host
Override: Not applicable
Status: Extension
Module: mod_rewrite.c
Compatibility: Apache 1.2

The RewriteLogLevel directive sets the verbosity level of the rewriting logfile. The default level 0 means no logging, while 9 or more means that practically all actions are logged.

To disable the logging of rewriting actions simply set Level to 0. This disables all rewrite action logs.
Notice: Using a high value for Level will slow down your Apache server dramatically! Use the rewriting logfile at a Level greater than 2 only for debugging!

Example:

RewriteLogLevel 3

Amnd here's an example of the rewrite log file:
Code:
68.53.33.78 - - [11/Aug/2009:18:29:59 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] internal redirect with /map.php [INTERNAL REDIRECT]
68.53.33.78 - - [11/Aug/2009:18:29:59 +0300] [www.domain.tld/sid#80dfb8c][rid#80ac2bc/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/map.php
68.53.33.78 - - [11/Aug/2009:18:30:07 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html
68.53.33.78 - - [11/Aug/2009:18:30:07 +0300] [www.domain.tld/sid#80dfb8c][rid#80abe34/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/index.php
68.53.33.78 - - [11/Aug/2009:18:30:13 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] rewrite news/ -> /map.php?forum
68.53.33.78 - - [11/Aug/2009:18:30:13 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] trying to replace prefix /home/www/www.domain.tld/public_html/ with /
68.53.33.78 - - [11/Aug/2009:18:30:13 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] internal redirect with /map.php [INTERNAL REDIRECT]
68.53.33.78 - - [11/Aug/2009:18:30:13 +0300] [www.domain.tld/sid#80dfb8c][rid#80ac094/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/map.php
68.53.33.78 - - [11/Aug/2009:18:30:14 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] rewrite maps/forum/ -> /map.php?forum=&maps&start=
68.53.33.78 - - [11/Aug/2009:18:30:14 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] trying to replace prefix /home/www/www.domain.tld/public_html/ with /
68.53.33.78 - - [11/Aug/2009:18:30:14 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] internal redirect with /map.php [INTERNAL REDIRECT]
68.53.33.78 - - [11/Aug/2009:18:30:14 +0300] [www.domain.tld/sid#80dfb8c][rid#80ac2bc/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/map.php
68.53.33.78 - - [11/Aug/2009:18:30:20 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html
68.53.33.78 - - [11/Aug/2009:18:30:20 +0300] [www.domain.tld/sid#80dfb8c][rid#80abe34/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/index.php
68.53.33.78 - - [11/Aug/2009:18:30:23 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] rewrite other-unix-os-f13.html -> /index.php?f=13&start=
68.53.33.78 - - [11/Aug/2009:18:30:23 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] trying to replace prefix /home/www/www.domain.tld/public_html/ with /
68.53.33.78 - - [11/Aug/2009:18:30:23 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] internal redirect with /index.php [INTERNAL REDIRECT]
68.53.33.78 - - [11/Aug/2009:18:30:23 +0300] [www.domain.tld/sid#80dfb8c][rid#80abef4/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/index.php
68.53.33.78 - - [11/Aug/2009:18:30:24 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] rewrite news/ -> /map.php?forum
68.53.33.78 - - [11/Aug/2009:18:30:24 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] trying to replace prefix /home/www/www.domain.tld/public_html/ with /
68.53.33.78 - - [11/Aug/2009:18:30:24 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] internal redirect with /map.php [INTERNAL REDIRECT]
68.53.33.78 - - [11/Aug/2009:18:30:25 +0300] [www.domain.tld/sid#80dfb8c][rid#80ac094/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/map.php
68.53.33.78 - - [11/Aug/2009:18:30:28 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] rewrite maps/forum/ -> /map.php?forum=&maps&start=
68.53.33.78 - - [11/Aug/2009:18:30:28 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] trying to replace prefix /home/www/www.domain.tld/public_html/ with /
68.53.33.78 - - [11/Aug/2009:18:30:28 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] internal redirect with /map.php [INTERNAL REDIRECT]
68.53.33.78 - - [11/Aug/2009:18:30:28 +0300] [www.domain.tld/sid#80dfb8c][rid#80ac2bc/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/map.php
68.53.33.78 - - [11/Aug/2009:18:30:36 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] rewrite news/ -> /map.php?forum
68.53.33.78 - - [11/Aug/2009:18:30:36 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] trying to replace prefix /home/www/www.domain.tld/public_html/ with /
68.53.33.78 - - [11/Aug/2009:18:30:36 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] internal redirect with /map.php [INTERNAL REDIRECT]
68.53.33.78 - - [11/Aug/2009:18:30:36 +0300] [www.domain.tld/sid#80dfb8c][rid#80ac094/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/map.php
68.53.33.78 - - [11/Aug/2009:18:30:36 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] rewrite maps/forum/ -> /map.php?forum=&maps&start=
68.53.33.78 - - [11/Aug/2009:18:30:36 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (2) [per-dir /home/www/www.domain.tld/public_html/] trying to replace prefix /home/www/www.domain.tld/public_html/ with /
68.53.33.78 - - [11/Aug/2009:18:30:36 +0300] [www.domain.tld/sid#80dfb8c][rid#80b6034/initial] (1) [per-dir /home/www/www.domain.tld/public_html/] internal redirect with /map.php [INTERNAL REDIRECT]
68.53.33.78 - - [11/Aug/2009:18:30:36 +0300] [www.domain.tld/sid#80dfb8c][rid#80ac2bc/initial/redir#1] (1) [per-dir /home/www/www.domain.tld/public_html/] pass through /home/www/www.domain.tld/public_html/map.php

_________________
Humble user
http://www.ivorde.ro





Top
Display posts from previous:  Sort by  
E-mail friendPrint view
Who is online
Users browsing this forum: No registered users and 0 guests
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
News News Site map Site map SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list


Delete all board cookies | The team | All times are UTC - 5 hours [ DST ]



phpBB SEO