SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,048
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod_rewrite causing PHP to count a view twice

    Hi Guys,

    I have a PHP script which enters the number of views a page has had into a database using the sql query below. However, if I enable mod_rewrite on the url to which the php script is working it counts the view twice. As soon as I turn off the mod_rewrite url it counts it once - as it should. It seems mod_rewrite is causing the script to run twice. How can I fix this?

    SQL query
    Code PHP:
    $this->dbh->query("update domains set views=views+1 where id='1'");

    mod_rewrite rules
    Code:
    Options +FollowSymLinks -MultiViews
    RewriteEngine On
    RewriteRule ^domains/([a-z0-9]+)/(.*)/? details.php?id=$1 [NC,L]

  2. #2
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi just a gander but try getting rid of 'Options +FollowSymLinks -MultiViews' and see if it works.

    Are you using a framework component for the database handler?
    Have a good day.

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,048
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Darren884 View Post
    Hi just a gander but try getting rid of 'Options +FollowSymLinks -MultiViews' and see if it works.

    Are you using a framework component for the database handler?
    Hi Darren,

    I have already tried getting rid of 'Options +FollowSymLinks -MultiViews' - but no joy!!

    Also, yes I am using PEAR framework.

  4. #4
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm what code is before or after it?
    Have a good day.

  5. #5
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,048
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Darren884 View Post
    Hmm what code is before or after it?
    Its okay, managed to fix it now using a session check.

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You probably have some rogue html, like an empty src attribute causing the browser to request the current url. Using sessions to fix this is an ugly wasteful hack.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •