Forum Moderators: phranque
I am writing a gallery script that has stats in it. Everything works well untill I tested the stats (every pageview should write 1 stats record to the database)
But when I checked 2 records were being written! I checked the whole code for hours, but could find a wrong query responseble for that... I checked the logs and there was the answer!
Mod rewrite is causing the second call to the page...! If I call the page without mod rewrite only one record is added.
So something is not wright, but I'm stuck...
Does anybody have any clue?
I'm getting desperate!
Development specs:
Apache2
windowsXP SP2
PHP5.x
mysql 5.x
My .htacces file:
RewriteEngine on
ReWriteRule ^p(.*)/c(.*)/t(.*)/g(.*)/(.*)-(.*)/$ gallery.php?pagenum=$1&cid=$2&tid=$3&gid=$4&pnum=$5&pmax=$6 [L]
From the logs --> through calling gallery.php:
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/gallery.php?pagenum=&cid=&tid=1&gid=12&pnum=1&pmax=1 HTTP/1.1" 200 6263
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/content/2/2/12/achtergrond_tjolk.jpg HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/banners/120x600.gif HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/css/menustyle.css HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/css/frame.css HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/i/menu_back_first.gif HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/i/menu_back.gif HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/i/menu_back_over_selected.gif HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/i/menu_back_last.gif HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/i/star.gif HTTP/1.1" 304 -
127.0.0.1 - - [19/Dec/2007:20:14:40 +0100] "GET /mfgs/ HTTP/1.1" 200 20276
from the logs --> through using the mod rewrite way:
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/p/c/t/g10/ HTTP/1.1" 200 7740
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/css/menustyle.css HTTP/1.1" 200 1442
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/css/frame.css HTTP/1.1" 200 2643
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/content/2/2/10/schot1_tn2.jpg HTTP/1.1" 200 4244
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/content/2/2/10/schot3_tn2.jpg HTTP/1.1" 200 3989
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/banners/120x600.gif HTTP/1.1" 200 47637
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/content/2/2/10/verdedigen_tn2.jpg HTTP/1.1" 200 3430
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/content/2/2/10/shot2_tn2.jpg HTTP/1.1" 200 4082
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/i/star.gif HTTP/1.1" 200 1002
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/i/menu_back_over_selected.gif HTTP/1.1" 200 150
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/i/menu_back.gif HTTP/1.1" 200 53
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/i/menu_back_last.gif HTTP/1.1" 200 130
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/p/c/t/g10/ HTTP/1.1" 200 7740
127.0.0.1 - - [19/Dec/2007:20:22:24 +0100] "GET /mfgs/ HTTP/1.1" 200 20276
RewriteRule ^p([[^/]+)/c([^/]+)/t([^/]+)/g([^/]+)/([^\-]+)-([^/]+)/$ gallery.php?pagenum=$1&cid=$2&tid=$3&gid=$4&pnum=$5&pmax=$6 [L]
Jim