mod_rewrite and php problems

    Date: 05/16/05 (Web Development)    Keywords: php, css, html

    I have a simple php file that inserts 1 row into a db. It's in a
    directory with a mod_rewrite in a .htaccess file. The mod_rewrite
    appears to be causing the php script to be run twice for every page
    request because it inserts two rows into the db for each page request.
    If I remove the .htaccess then it works fine. Can someone tell me why
    this is happening and how I can fix it? Here is my php file

    test.php
    ---------------------------
    $db = mysql_connect('localhost', 'xxxxx', 'xxxxx');
    mysql_select_db('xxxxxx');
    echo 'create cache' . "
    \n";
    $query1 = "insert into searches (keywordId, relatedId)
    values('1','764419')";
    mysql_query($query1);
    ?>
    ---------------------------

    here is my .htaccess
    ---------------------------
    Options FollowSymLinks
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} .*sitemap(.*).html.*
    RewriteRule ^(.*)$ sitemap.php [L]

    RewriteCond %{REQUEST_FILENAME} !.*main.css.*
    RewriteCond %{REQUEST_FILENAME} !.*sm.css.*
    RewriteCond %{REQUEST_FILENAME} !.*banner.gif.*
    RewriteCond %{REQUEST_FILENAME} !.*disclaimer.html.*
    RewriteCond %{REQUEST_FILENAME} !.*sitemap.php.*
    RewriteCond %{REQUEST_FILENAME} !.*index.php.*
    RewriteCond %{REQUEST_FILENAME} !.*test.php.*
    RewriteCond %{REQUEST_FILENAME} !.*404.html.*
    RewriteRule ^(.*)$ index.php

    Source: http://www.livejournal.com/community/webdev/200040.html

« Crossposting || Community promotion »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home