Write Review

SEO is the most talked topic on the web right now. Everyone is trying to achieve something others don't. You will be amazed to know that even the search results of your WordPress website play a vital role in SEO.

If you look at the pages and posts, you can find SEO-friendly URLs. Thanks to SEO plugins, which allow its user to leverage a website for a perfect SEO score.

In the last couple of years, people have started realizing how important it is to follow the latest Google trends. As you know, even the page loading time of a site impacts its SEO.

In today's tutorial, you're going to learn about changing the default search URL slug to an SEO-friendly slug without using any plugin.

As you have already read, we're going to use the .htaccess file, but you should also know that the same task can be accomplished using the functions.php file.

But today, I am going to provide you with the .htaccess code.

A Step By Step Guide to Change the Default Search URL

By default, WordPress search URL isn't SEO-friendly. Let me give you an example.


You can easily tell that such a URL isn't understandable.

If you're a regular WordPress user, you may already know how vital .htaccess is to a WordPress site. The file handles all the rewrite rules and many other concepts.

I hope you know how to edit .htaccess. There are two different ways. You can either use FTP or cPanel. In this tutorial, I am going to show you the cPanel method.

Even the cheapest web hostings allow access to cPanel.

Let's start the process.

Step 1:

As usual, you need to login to your web hosting cPanel account and

look for the file manager
, where all the data of your site is residing.

How to Modify the Search URL Slug Using .htaccess for a Better SEO Score

Most of the web hosting companies keep the file manager under the Files' section. Even though you don't have the reputed web hosting, you can still find the file manager.

Almost every reliable web hosting cPanel access.

Step 2:

Make sure you open the public_html directory because by default a home directory may open up.

Expand the public_html directory from the sidebar of cPanel

How to Modify the Search URL Slug Using .htaccess for a Better SEO Score

Step 3:

Now you can see all the files and folders of a WordPress site.

Scroll a bit, and you can find the .htaccess file
, if you don't see it, you need to change the cPanel settings from the top-right corner.

How to Modify the Search URL Slug Using .htaccess for a Better SEO Score

Check the box to show hidden files for the chosen domain.

Step 4:

Refresh the page and seek for the .htaccess file. Right-click to edit
. You can also use the common Edit link from the main navigation menu.

How to Modify the Search URL Slug Using .htaccess for a Better SEO Score

Step 5:

A popup appears to confirm that you understand the meaning of editing such an important file.

Click on the Edit link to continue

How to Modify the Search URL Slug Using .htaccess for a Better SEO Score

Step 6:

A new tab opens up in the web browser where you can notice numerous coding lines.

Copy and paste the code in the file before #End WordPress
. Click on the Save Changes button from the top-right corner.

# Change the WordPress Search URL
RewriteCond%{QUERY_STRING} \?s=([^&]+) [NC]
RewriteRule ^$ /search/%1/? [NC,R,L]

Once you add it, the search URL becomes http://yoursite.com/search/search-query

Do You Think You Can Modify Search URL

Every time something new comes up, you may fret, and it's obvious. But you should understand that WordPress keep evolving with time.

You need to be prepared for new challenges. Modifying the default search URL slug helps you improve the overall SEO of your site.


There are different methods to accomplish one task, and it's always important to choose the convenient way. I hope it wasn't difficult to add the code in .htaccess.

Follow the steps and within a few minutes, you can have an SEO-friendly search URL.

Check out these top 3 WordPress hosting services:

Was this article helpful?