Clean Permalinks for Search Results
Filed Under: Blogging, WordPress
Here is a little tip to force WordPress to use clean permalinks for search results. Despite using pretty permalinks you may have noticed WordPress returns search results as yoursite.com/?s=SEARCHTERMS instead of yoursite.com/search/SEARCHTERMS. I’ll show you how to achieve the latter.
First of all, create a new file called search.php which contains the following,
<?php header('Location: http://www.yoursite.com/search/' . $_GET['s']); ?>
Upload that file to root. Next, look in your theme’s folder for the searchform. Change the action to,
action="<?php bloginfo('url'); ?>/search.php"
All done. Test it out for yourself. Type the term WordPress in the search engine and look at the URL.
Further reading:
http://codex.wordpress.org/FAQ_Advanced_Topics
Thanks for visiting! If this is your first time here why not grab the RSS feed. You can also follow this discussion by checking the "Notify me of followup comments via e-mail" box or by subscribing to the comments RSS feed. Please scroll down to leave your comment.




No Comments so far. Add Yours Now!
Reply to “Clean Permalinks for Search Results”
Please note: Comment moderation is in effect. It may take some time for your comment to appear. There is no need to resubmit it.
Management does not necessarily endorse or agree with comments left here. Management reserves the right to not publish comments it deems unfit. Play nice.