Note that there are some explanatory texts on larger screens.

plurals
  1. POrewrite based accesslog using apache + mod_rewrite - possible?
    primarykey
    data
    text
    <p>we have a bunch of mod_rewrite rules.</p> <p>these are simple URI + GeoIP Continent = R=302,L rules.</p> <p>they work great. we have tested using boxes on various continents and everything works as expected.</p> <p>we would like to add a final rule that simply enables an access log for requests that have not matched any of the 'above' rules, but allows the request to be fulfilled as requested. just so we can get a more clear insight as to whats making it thru all the rules un-redirected.</p> <p>possible using apache2 + mod_rewrite?</p> <hr> <p>how we accomplished this, as the answer by regilero states below (credit is all his):</p> <p>1)</p> <p>at the end of the rewrite rules, we added a rule that was sort of a catch all for the specific file we wanted to log. we used the E=envname:value as regilero stated.</p> <pre><code>RewriteRule ^filename.ext$ filename.ext [L,E=logme:true] </code></pre> <p>2)</p> <p>we then added the following customlog entry</p> <pre><code>CustomLog /var/log/httpd/your_custom_log.log "%v:%p | %r | %{User-agent}i" env=logme </code></pre> <p>as you can see, env=logme. basically meaning if variable logme is set, customlog that shizzle.</p> <p>the above customlog is fairly minimal, we just want to know the server:port | requested url | useragent. you can change it as you see fit using the "Custom Log Formats" found in <a href="http://httpd.apache.org/docs/2.0/mod/mod_log_config.html" rel="nofollow">http://httpd.apache.org/docs/2.0/mod/mod_log_config.html</a>.</p> <p>3)</p> <p>using the above we are able to find out what (if anything) is making it thru our slightly complex (useragent + geoip continent) rewrite rules and act on this information accordingly.</p> <p>a final note: although we did not do any real empirical testing, im sure these 'catch all' rewrite rules are fairly heavy. so ideally, you will only want to do this as a decision making tool and turning them off once you decide the correct course of action. although im sure that all depends on how busy your web property is ;)</p> <hr> <p>this is VERY useful. using this method you can log all sorts of activity. once again, a heart felt thank you to regilero. we will be using this all over.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload