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

Rewrite wordpress search url

Discussion in 'PHP & Perl' started by le-bouzin, May 23, 2011.

Tags:
  1. le-bouzin

    le-bouzin Newbie

    Joined:
    Feb 15, 2010
    Messages:
    8
    Likes Received:
    0
    Hi there,I'm lookin for a php function or htaccess rewriting for wordpress earch query.This query is built this ways : domain/?s=queryterms1+queryterms2 and can contains upper and lower case, and digits and any special character. I need this query to be rewritten into domain/search/queryterms1+queryterms2.html
     
  2. 5VM5UN6

    5VM5UN6 Registered Member

    Joined:
    Jun 18, 2009
    Messages:
    51
    Likes Received:
    9
    .htaccess should look something like this
    Code:
    RewriteEngine On
    RewriteRule ^/search/([\w\d\+]+).html$ index.php?s=$1 [L]
     
  3. le-bouzin

    le-bouzin Newbie

    Joined:
    Feb 15, 2010
    Messages:
    8
    Likes Received:
    0
    thanks for your reply.

    Actually I use rewriting options si index.php is already rewrited and your code do not work.

    Here is my current htacces :

    PHP:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase 
    /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteRule 
    . /wordpress/index.php [L]
    /
    IfModule>

    # END WordPress

    I tried to use this rule with no luck :
    RewriteRule ^/search/([\w\d\+]+).html$ /?s=$1 [L]
     
  4. andey

    andey Newbie

    Joined:
    Jul 1, 2011
    Messages:
    8
    Likes Received:
    2
    Occupation:
    Rails Developer
    Location:
    Miami | Toronto
    there is a plugin called "nice search"
     
  5. le-bouzin

    le-bouzin Newbie

    Joined:
    Feb 15, 2010
    Messages:
    8
    Likes Received:
    0
    Thnaks you Andey, was what I looking for !