WordPress.org

Forums

[resolved] Supporting multiple search options with mod_rewrite (2 posts)

  1. Nighthound
    Member
    Posted 9 years ago #

    I have implemented tags on my blog with UltimateTagWarrior. I want to extend the search function so that I can search either posts or tags using the same search field.

    Basically I went about implementing the search form with two submit buttons, one to submit

    /?str=<blah>&submit=Search

    and the other

    /?str=<blah>&submit=Tag

    Now I need to add rewrite rules to map the first to

    /index.php/s=<blah>

    and the second to

    /index.php/tag=<blah>

    I've tried using the following but it doesn't seem to work:

    RewriteRule ^?str=(.*)&submit=Search$ /index.php?s=$1 [QSA,L]
    RewriteRule ^?str=(.*)&submit=Tag$ /index.php?tag=$1 [QSA,L]

    Can anyone give me some pointers?

  2. Nighthound
    Member
    Posted 9 years ago #

    Nevermind, I found the solution:

    RewriteCond %{QUERY_STRING} ^str=([^&]+)&submit=Search$
    RewriteRule ^(.*)$ /index.php?s=%1 [L]
    RewriteCond %{QUERY_STRING} ^str=([^&]+)&submit=Tag$
    RewriteRule ^(.*)$ /index.php?tag=%1 [L]

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags