How do you get cruft free URIs for search results?

To return clean URIs for search results in WordPress from the search form (www.example.com/search/searchterms instead of http://www.example.com/?s=searchterms)

First create a file called search.php which contains:

header('Location: http://www.example.com/search/' . $_GET['s']);

Put that file in the root of your WordPress install and alter the action for the search form to this:

action="/search.php"

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s