mod_rewrite messing up header queries
I have a lot of mod_rewrites in 开发者_如何学编程a local .htaccess file which basically follow this template:
RewriteRule ^page\/?$ /page.php [L,QSA]
Each of these pages has a header.php include that contains a single SQL insert:
$new_visit = $db->prepare("INSERT INTO stats (ip_address, clientdata, page_title, timestamp) VALUES (?, ?, ?, UTC_TIMESTAMP())");
$new_visit->execute(array($ip, $clientdata, $page_title));
The problem is that every time a page is visited, $new_visit is called three times instead of one: once for the actual page in question, and two duplicates (which interestingly use "index.php" for $page_title no matter what the redirected page was).
If anyone could help me fix this while leaving both mod_rewrite and some semblance of my visitors system intact, I'd be much obliged.
I have a lot of mod_rewrites in a local .htaccess file
^ that's your problem.
I ran into a similar case where I simply wasn't sure what was happening. Turns out that an image didn't exist so the system couldn't generate a link to it, so instead it generated a link to index.php (or something similar). The browser then fetched that script as if it were expecting an image. This explained my 'ghost' request.
精彩评论