WordPress.org

Ready to get started?Download WordPress

Forums

Permalink for search result pages (12 posts)

  1. Miroslav
    Member
    Posted 7 years ago #

    I wish to provide links to predefined search result pages. Would anybody be able to share the rewrite rule to use?

    I want my URLs to look like:

    http://www.mysite.com/some-folder/search-term/ and
    http://www.mysite.com/some-folder/search-term/2/ (for paginated results)

    ...instead of:

    http://www.mysite.com/?s=Search+Term (note: the use of title case is intentional, but I want the rewritten URL in lowercase)

    Thanks in advance!

    [BTW, I am using WP 2.1.2]

  2. Adam Brown
    Member
    Posted 7 years ago #

    There's two steps involved. First, you need to create the htaccess rules. Then, you'll need to make it so the search form points to the desired location. Since you ask only about the first, I'll assume you have the second covered.

    Try pasting something like this into your htaccess:

    RewriteRule /some-folder/(.*)/?(.*) WORDPRESS/?s=$1&paged=$2

    Obviously, replace WORDPRESS with your path to wordpress. And that should all be on one line, not wrapped like it shows up here.

  3. Miroslav
    Member
    Posted 7 years ago #

    Thanks, Adam! Will give it a try. :)

  4. Robert Simpson
    Member
    Posted 6 years ago #

    adamrbrown: How would I go about the second part? I'm looking at searchform.php right now and I can't work it out.

    Cheers,
    Robert

  5. Robert Simpson
    Member
    Posted 6 years ago #

    *bump*

  6. mmoraes
    Member
    Posted 6 years ago #

    Any chance of having WordPress' permalink for search as http://www.mysite.com/<KEYWORDS>?

    Where <KEYWORDS> would be the keywords.

    Ex: http://www.mysite.com/wordpress+plugins

  7. moshu
    Member
    Posted 6 years ago #

    Not really. It will be
    example.com?s=wordpress+plugins

  8. mmoraes
    Member
    Posted 6 years ago #

    Actually I found a plugin (called "Search Permalink") that does the trick without touching the .htaccess file.

    Problem is that WP returns 404 not found thinking I'm looking for an static page...

  9. moshu
    Member
    Posted 6 years ago #

    thinking I'm looking for an static page...
    That's exactly why it will not work.

  10. whooami
    Member
    Posted 6 years ago #

    yeap, you cant do that mmoaraes, best you can hope for is going to be something like so:

    http://www.village-idiot.org/search/wordpress+spam

  11. mmoraes
    Member
    Posted 6 years ago #

    OK, thanks. I opened another topic to discuss this:
    http://wordpress.org/support/topic/141451

  12. mmoraes
    Member
    Posted 6 years ago #

    @whooami
    @moshu

    Nevermind. Got it working doing some tricks with Redirections plugin: http://urbangiraffe.com/plugins/redirection/

    Thanks anyway!

Topic Closed

This topic has been closed to new replies.

About this Topic