How to Modify the Default Search URL Slug in WordPress

Do you wish to modify the default search URL slug in WordPress site? By default slugs also known as URL’s are not user friendly in WordPress. Here in this article we are going to discuss how to modify the default search URL slug in WordPress hosted on WordPress hosting account.


Why Modify Default Search URL Slug in WordPress


WordPress utilizes SEO friendly as well as user friendly URL structure for all pages on a website. Generally SEO friendly URLs look similar to:


Are you see the above URLs are much easier to understand for users at the same time for search engines.


Although WordPress CMS still utilizes non-friendly URL for search engine result page. An usual search URL looks similar to :


This specific URL structure does not looks similar to the other URLs of website . At the same few WordPress search plugins enhance the search results, maximum do not perform anything related the search engine URL itself.


Consider the possibility that you can influence your search URL to look similar to.

Let us know explain how to make the WordPress search URL slug more Search engine friendly,.


Modifying Search URL Slug in WordPress


To perform this action you need to modify your WordPress theme files. In case you have not tried this before, then contact our support team.

Modify WordPress Search URL Slug through Functions File

This is one of the simple and easiest way and recommended for most of the users.

First of all, you have to copy & paste the code given below inside your theme’s functions.php file or a site-particular plugin:


function wpb_change_search_url() {

   if ( is_search() && ! empty( $_GET['s'] ) ) {

       wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );




add_action( 'template_redirect', 'wpb_change_search_url' );


Do not forget to save the changes you have done.

Once you are done, go to your website and try to search. You will discover that the search URL slug looks similar to :


Modify Search URL Slug through htaccess File

The htaccess file in available in your control panel and mostly used to create redirects and other website related configurations. You can also use .htaccess file to modify the search URL slug in WordPress hosting.


The .htaccess file is situated in the root folder of a domain name. In order to access it you need to login to cPanel or FTP of your WordPress hosting account.


Copy the following code and paste it at the bottom of .htaccess file:


# Modify WordPress search URL Slug

RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]

RewriteRule ^$ /search/%1/? [NC,R,L]

Do not forget to save the changes you have done and then upload the .htaccess file to your server again.

Now you need to visit your website and utilize the search option to see the changes, it will show like this:


Hope this article helped in modifying the default search URL slug in your WordPress hosting account.

How can I move Wordpress from one URL to another URL?

If you are looking to create your own website without the help of a developer and if you want to design it as per your need then going with Wordpress hosting is one of the right way where you can easily create, design and host your own website. And today WordPress hosting services have been in high demand as its popularity is growing as a blogging application. One of the biggest advantages of using WordPress hosting solution is that you no need to have the special skills on CSS or HTML to run your website. Not only that WordPress is an astounding tool, and it is also one of the most trouble-free content management systems on hand. But today if you are already using a WordPress solution for your website and if you are looking for a detailed information on how to move Wordpress from one URL to another URL? then here is the complete information on it.

How can I move Wordpress from one URL to another URL one


Follow the below steps to change one URL to another URL:

Changing one URL to another URL in WordPress is not an easy task and in here you need to see that other scripts in which you would have a configuration file only that you file you need to edit. And in WordPress, all the configuration which you have changed will be located inside your database.  

How can I move Wordpress from one URL to another URL two

So if you want to change there are 3 main things that you need to change you can see in the below command-

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, '','');

UPDATE wp_posts SET post_content = replace(post_content, '', '');

And now all you need to do is that to change your old domain section to the new domain and now in here you need to paste that into the SQL section inside phpmyadmin.

If you are looking for best WordPress hosting for your website then here at right place because at HostingRaja we provide best in class WordPress hosting solution at an affordable price. Not only that we also provide amazing features, offers, and discounts. We provide fully managed WordPress hosting and we will also install and set up a WordPress for you on your WordPress hosting plan. We also provide WordPress theme worth Rs. 6000 for free with our WordPress hosting plan. We also provide 99.9% server uptime guarantee and also provide 24/7 customer support via phone, chat, email and ticket system.