Lightning Rank - Private Blog Network

  • Home
  • Done 4 You PBN Service
  • Other Services
    • Amazon Associate Audit
    • Editorial Links
    • Buy Expired Domains
  • Contact
    • Affiliates

Pretty WordPress Search URLS Without Plugins

November 20, 2015 By Jon Gillham Leave a Comment

This tutorial will show how to easily transform your WordPress search urls into a more readable and frieindly rewrittend structure instead of the default url which contains ?s= and without using any additional WordPress plugins.

With a default installation of WordPress and when url rewriting is enabled the search url’s remain unaffected. The default WordPress search query for wordpress plugins for example outputs the url like below.

http://sitespex.com/?s=wordpress+plugins&submit=Search

What this tutorial will do is change the output of your WordPress search urls usuing the WordPress wp_redirect function to look like the example below which as you can see is a much cleaner url output.

http://sitespex.com/search/wordpress+plugins

Open your themes functions.php file and paste the code below into it, save that file then go check out your new search urls.

function search_url_rewrite(){
        if(is_search() && !empty($_GET['s'])){
                wp_redirect(home_url("/search/"). urlencode(get_query_var('s')));
                exit();
        }
}
add_action('template_redirect', 'search_url_rewrite');

Let us know if you have any improvments or have any errors with this code snippet in the comments.

Filed Under: Wordpress Tutorials Tagged With: pretty urls, url rewrite, wordpress hack, WordPress Search URLS, wp_redirect

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • What It takes to get to #1 in Google
  • Private Blog Network Building Service in 2016 – Is It Still Worth The Risk?
  • UpThemes Scale Back On Theme Options Within Their WordPress Themes
  • Create A WordPress Login Form Shortcode For Your Blog
  • WooThemes Back Online After Malicious Hack & Further DDoS Attack

Our Team

Jon Gillham

Father, Husband and mechanical engineer. Jon has the easy job he builds and tests systems that Kelley, Hmd and their teams execute!
Ahmed Ali

Ahmed is the man that makes sure everything runs smoothly. A true jack of all trades he makes sure each site is built to our high standards!

Copyright © 2022 . Experts at Harnessing the Power of Expired Domains to Help You Outrank Your Competition