WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] search clean url - no ?s= (19 posts)

  1. somefool
    Member
    Posted 9 years ago #

    right, I see Wp 1.5 seems to support clean urls for search out of the box. Mine atleast least me do http://www.somefoolwitha.com/search/apple rather than http://www.somefoolwitha.com/?s=apple for example.

    Now to the nub of my question, HOW do I get the search box in WP to return the clean url instead of the ?s= one?

    Ive searched through the WP code for ?s= but I cant find anything in the code, so whats going on?

    Looks like others wanted an answer in November! http://www.noscope.com/journal/2004/07/separate_search_page/

  2. oriecat
    Member
    Posted 9 years ago #

    I just did a search on your site and it brings up the clean urls?

  3. somefool
    Member
    Posted 9 years ago #

    are you sure, a search url is still ....com/?s=searchterm

  4. oriecat
    Member
    Posted 9 years ago #

    Oooh, I thought you meant the urls on the results list. Yeah the url of the search page is the s=...

  5. somefool
    Member
    Posted 9 years ago #

    i thought that was clear ;-)

  6. oriecat
    Member
    Posted 9 years ago #

    yeah, now that i read it again... :) Sorry! No more helping until the coffee kicks in....

  7. Davin
    Member
    Posted 9 years ago #

    "somefool": Any hints on your process for linking to /search/keyword with WP1.5? Did you need to create a page with "search" as the slug?

  8. m4c3w4n
    Member
    Posted 9 years ago #

  9. Davin
    Member
    Posted 9 years ago #

    Disregard my question above. I think what "somefool" is referring to is that you can type an url such as "blah.com/search/keyword" manually and it's a clean working url but if you use the search form it still spits out an "index.php?s=keyword".

    The only thing I can think of is pointing the search form to an interim PHP page which captures the keyword(s) and redirects to an appropriately formed clean url.

  10. Kafkaesqui

    Posted 9 years ago #

    This came up in a Hackers list thread a few months back:

    http://comox.textdrive.com/pipermail/wp-hackers/2005-April/000719.html

  11. Davin
    Member
    Posted 9 years ago #

    Okay I just tried this...

    I made a new PHP file that just had this in it:

    <?php header("Location: http://www.SITE.com/search/".$s); ?>

    Then I just set the search form action to point to the new PHP file. I'm not a programmer by any means but that seems to work.

  12. somefool
    Member
    Posted 9 years ago #

    Ok, cheers Davin Ill give that a try.

    I did think my question was clear, but obviously I was wrong ;-)

  13. somefool
    Member
    Posted 9 years ago #

    Hmm, Ok, what am I doing wrong?

    Bearing in mind that Ive got livesearch on my site, heres what Ive done. I removed the name="s" attribute which seems to make it go to ?s=

    Now it just bounces on to site.com/search/ it doesnt seem to bring the search terms with it

    --
    <form style="float:left; padding:0px;" onsubmit="return liveSearchSubmit()" id="searchform" name="searchform" method="get" action="<?php bloginfo('url'); ?>/search.php" autocomplete="off">
    <input style="width:170px;" type="search" results="5" autosave="ssave" id="livesearch" value="Search" size="20" onkeypress="liveSearchStart()" onblur="setTimeout('closeResults()',2000); if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'search blog archives') {this.value = '';}" class="inputboxes" />
    <input type="submit" id="searchsubmit" style="display: none;" value="Search" />
    <div id="LSResult" style="display: none;"><div id="LSShadow"></div></div>
    </form>
    --

  14. somefool
    Member
    Posted 9 years ago #

    oops, scrattch that, it needs the name="s" and works fine :-)

    cheers guys ;-D

  15. somefool
    Member
    Posted 9 years ago #

    If someone knows where best to place it, Ill stick this on the codex - when it works again

  16. somefool
    Member
    Posted 9 years ago #

    So, anyone any ideas where best to add this to the codex?

  17. somefool
    Member
    Posted 9 years ago #

  18. MichaelH
    Member
    Posted 9 years ago #

    somefool--thanks for the contribution to Codex. Your explanation has been moved to:
    How to get cruft free URIs for search results? at Codex FAQ Advanced Topics

  19. somefool
    Member
    Posted 9 years ago #

    Cool! Cheers, i wasnt sure what I was doing really, or where exactly to put it, but I thought best to stick it up there asd it can always be moved around by someone more knowledgeable than me.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags