Pretty Url in WordPress Search Result
WordPress, the search url is not pretty, I mean it’s not search engine friendly (uses query string), it looks something like
http://example.com?s=foo and it’s doesn’t look very professional. So, if you want to change the url to something like
http://example.com/search/foo then it’s possible and very easy, just 2 steps.
Step 1 :
Create a file called
search.php which contains following code
header('Location: http://www.example.com/search/' . $_GET['s']);
Now put the file in the root of your WordPress install.
Step 2 :
action attribute of the search form to
<?php bloginfo('url'); ?>/search.php, i.e.
<form method="get" action="<?php bloginfo('url'); ?>/search.php">
<input type="text" size="16" name="s" />
<input type="submit" value="search" name="submit" />
That’s it. Now the search url will look really pretty something like
https://heera.it/search/foo, which looks professional and search engine friendly too, isn’t it very simple ? I think it is.