Basic hit counter also affecting images?

56 Views Asked by At

I have recently added a hit counter to my page to see what domains people are coming from. Since I have two domains that point to the same IP, which I recently have acquired.

All requests go to my index.php file, which determines how to display the page. I have it set up like so, because I plan on having multiple pages, like user pages or forum posts, and can't have a multitude of folders. .htaccess is set up like so:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/phpmyadmin/?$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php [NC,L,QSA]

At the start of my index.php I have:

(Bit of code that determines the domain used)
$conn = connectDB();
$result = $conn->query('UPDATE hitCounter SET hits = hits + 1 WHERE domain = "'.$domain.'"');
$conn->close();

However, images count as a hit. If I were to go to domain.com/img/img.png It would count as a hit. How can I stop it from doing this? (I have a bit of javascript, that makes particles to 'fall' from the top. This caused the number of hits go up by 1000 in an hour)

0

There are 0 best solutions below