SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot websalacarta's Avatar
    Join Date
    May 2003
    Location
    Spain
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess loop problem

    Hi, Im using one easy .htaccess file.
    The problem is that the page is been called 3 times, instead of one.

    do you see anything wrong with my file?

    thanks very much

    PHP Code:
    RewriteEngine on

    #loop stopping code.
    RewriteCond %{ENV:REDIRECT_STATUS200
    RewriteRule 
    ^ - [L

    RewriteRule search/([^/]+) searchresult.php?search=$[L

  2. #2
    SitePoint Zealot websalacarta's Avatar
    Join Date
    May 2003
    Location
    Spain
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I´ll try to explain it better.

    I have one counter on the page

    if I write
    PHP Code:
    http://mydomain/searchresult.php?search=aaa 
    The counter is counter +1

    if I write

    PHP Code:
    http://mydomain/search/aaa 
    The counter is counter +3
    (sometimes it´s counter + 2)

    I think the problem can be on .htaccess file?

    Thanks for your help

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    wsc,

    I think that the problem is that your "loop preventer" is really not required in this instance - and likely forces another pass through the mod_rewrite. Comment that out and see whether that makes a difference or not.

    Because you didn't say what was counting the hits, I have to guess it was code within the page - which would NOT be processed until mod_rewrite is done with its job and redirected the request to the searchresult script. IMHO, look there for the cause.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  4. #4
    SitePoint Zealot websalacarta's Avatar
    Join Date
    May 2003
    Location
    Spain
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi dklynn,
    thanks for your help

    I added "loop preventer" lines trying to solve the problem I had.

    The original .htacces file is:

    Code:
    RewriteEngine on
    RewriteRule search/([^/]+) searchresult.php?search=$1 [L]
    The page updates one table, something like
    ...UPDATE... SET VIEW = VIEW + 1...

    The problem is what I said before, sometimes it adds 3 instead of 1
    (I am the only person visiting this page)

    Thanks.

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    wac (sorry for the error above),

    I think this is a PHP coding error. If you want to show the surrounding code here (or PM if you're not comfortable posting the script here), I can help you though it or you might want to take it to the PHP forum. I think there is a loop in your code which causes that query to be executed three times rather than the once you've intended (again, because the mod_rewrite redirect is only applied once THEN the script is executed).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    SitePoint Zealot websalacarta's Avatar
    Join Date
    May 2003
    Location
    Spain
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Thanks for your help.

    You are rigth, the problem is not with apache, it´s with code.

    The incredible thing is that everything works correctly when I comment these lines:

    Code:
    <!--
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    -->
    anybody understand anything?


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
  •