1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

RewriteRule in URL for search engine with pagination

Discussion in 'PHP & Perl' started by funque, Jan 3, 2014.

  1. funque

    funque Newbie

    Joined:
    Dec 27, 2013
    Messages:
    21
    Likes Received:
    1
    I have Htaccess file and pagination search engine, it is my search engine forms
    Code:
    <form class='fright' method='get' action='hasil_cari=' onsubmit="return false;">
    
          <input class='srcText' style='padding:6px;'type='text' name='keyword'>
          <input class='submit' style='padding:5;' type='submit' value='find' onclick="window.location.href=this.form.action + this.form.keyword.value;">
    
    </form>
    
    this is my RewriteRule to original url:
    Code:
    RewriteRule ^admin/keyword=(.*)-page=(.*)$ admin/index.php?h=home&m=find&keyword=$1&p=$2 [L]
    
    in the address bar of my browser:
    localhost/project/admin/keyword=....-page=2

    then I click on page 2, but '-page=2' is read as a keyword, so the error message that I have created appear

    "cannot find data = .....-page2"

    anyone can solve this problem?
     
  2. tripper_john_md

    tripper_john_md Newbie

    Joined:
    Feb 21, 2011
    Messages:
    40
    Likes Received:
    35
    Location:
    Southern Germany
    You are using greedy matches, you are basically saying: match any character and match them all!
    So your url part "-page=2" gets selected, too.
    Try using something like this:
    Code:
    admin/keyword=([^-]+)-page...
    It excludes the - from the first part. If your keywords could contain a minus, you'd have to change it further, like this:
    Code:
    ^admin/keyword=([(?!-page)]+)-page...