Thanks for that Jim, appreciate it ! But in fact, things are even more complex, I just tried to simplify & abstract here - and the thread went the wrong direction. Sorry for being misleading ! What I wanted is a working
RewriteCondition that I would transform into an
EXCLUDE rule. OK, let me explain my setup here in depth. The actual rewriting/redirecting to the PHP script on the other domain on my server (including the URL parameter) was working from the very beginning. I am working with two .htaccess files here, one on the server that gets the traffic (that has the <img src="counter.gif?r=http://www.referrer.com"> on it) and the other one on my own (shared) server. On the later I am using a GLOBAL .htaccess file for all my domains, and the PHP counter script (counter.php) has to be on a domain with WordPress installed on it, the URL permalinks are being re-written by the global .htaccess file. The counter.php file is in the root of that domain, the blog is inside a /subfolder and is being redirected from www.domain.com to www.domain.com/blog. What I need to do now is on MY server's .htaccess file to exclude it from rewriting (permalinks) and redirecting (to the /blog subfolder). That's basically the whole story. As I said, pretty tricky and I couldn't get it to work with the code above, i.e.
RewriteCond %{QUERY_STRING} !^r=.
or
RewriteCond %{THE_REQUEST} !^[A-Z]+\ /counter\.gif\?r=.
...isn't working (tried together and separate) when there is an URL passed inside the parameter. The condition just won't match anymore if 'http://' is included. However, omitting the 'http://' part it works as expected, gets excluded and is NOT being rewritten/redirected. This is the only goal I have and the reason for this thread here !
Never mind, I keep trying. To be honest, I'm still not very familiar with RegEx even though my global .htaccess file is already full of it, I get easily confused and it's a real pain working with it. There should be a '
logging feature' for debugging rules, invokable from inside the .htaccess file itself (not via server config only, which is inaccessible on shared hosting). Also I'd like to measure the
processing time to see the impact of having many rules included, but this is not possible either. Furthermore, why nobody at ASF (Apache Software Foundation) considered an '
inheritance' or '
include' option
for .htaccess ? This would be sooo convenient ! Having a global .htaccess file with - say - IP deny rules and separate, domain specific .htaccess files for each domain (inside their own root directories). In all (web) programming languages there is an option to include code from external sources, so why not including it in .htaccess ? Why must it be that messy and such a pain working with .htaccess anyway ? Every programming language I know is way easier to understand and more logical compared to that. It's such a pain... spending hours or even days to get some non-trivial rules to work. Maybe it's just me and the RegEx I need to look more into. But we live in 2010, it's such a shame :(
So what I did now is I filed a bug report regarding the non-working SSI echo encoding in mod_include at Apache.org bugzilla bugtracking system ([
issues.apache.org ]). I bet I only have the JavaScript option left now. I wanted to avoid this as 1) bots usually don't execute JS, but I want to track them as well, and 2) JS can be disabled in the browser or filtered by software. So I though the <img> version would work better to track all traffic, including Robots. I might be wrong.
But thanks again !