Forum Moderators: phranque

Message Too Old, No Replies

How to prevent the original request from enterring access log

redirection using mod_rewrite

         

jinhh

9:48 pm on Mar 31, 2009 (gmt 0)

10+ Year Member



Hi, Everyone:

I am using the following code in httpd.conf file to redirect any request using my ExitPage program to an information page:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*ExitPage.*$
RewriteRule ^.*$ /LinkTempNotAvailable.html [R,L]

It works but I don't like the fact that original request was also recorded in the log file:
.........
***.***.***.*** - - [31/Mar/2009:17:26:45 -0400] "GET /cgi-bin/ExitPage/MyProgram.cgi?url=http://www.website.com HTTP/1.0" 302 269
.........

Is it possible to get rid of this line? I was not allowed to modify the log file after it was generated.

I am using apache 2.0.59 on Solaris.

Any comments and hits will be appreciated.

Jin

Caterham

5:39 pm on Apr 1, 2009 (gmt 0)

10+ Year Member



Use conditional logging. Set an ENV with the e flag like

E=dontlog:dummy

and use a condition for the customlog like
customlog ...... env=!dontlog

jinhh

6:52 pm on Apr 1, 2009 (gmt 0)

10+ Year Member



Hi, Caterham:
Thank you very much for the reply. It is a solution. But I found I can not use it. I am using the TransferLog:
TransferLog "¦/usr/local/sbin/cronolog /var/rithqnuas003/logs/daily/rithqnuas003_01_%Y%m%d.log"

When I add "env=!dontlog" at the end, I got the following error:
"TransferLog takes one argument, the filename of the access log".
I tried to replace TransferLog with CustomLog, But failed also.

Do you have any further comments? Is it possible to use Mod_rewrite to solve my problem?

Thank you again for your time and help.

Jin

jdMorgan

7:01 pm on Apr 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



in httpd.conf:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*ExitPage.*$
RewriteRule ^.*$ /LinkTempNotAvailable.html [[b]E=dontlog:True[/b],R,L]

Then define a custom logging format (see Apache mod_log_config [httpd.apache.org]), and include env=!dontlog at the end of the CustomLog directive that invokes it.

jinhh

8:07 pm on Apr 1, 2009 (gmt 0)

10+ Year Member



Hi, jdMorgan and Caterham:

Thank you for the help and it is working.

Here is the related code I am using in my httpd.conf:
-----------------------------------
LogFormat "%h %v %u %t \"%r\" %>s %b" common
CustomLog "¦/usr/local/sbin/cronolog /var/rithqnuas003/logs/daily/rithqnuas003_01_%Y%m%d.log" common env=!dontlog
.....
.....
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*ExitPage.*$
RewriteRule ^.*$ /LinkTempNotAvailable.html [E=dontlog:True,R,L]
-----------------------------------
Jin