Do you want to change the default search URL slug in WordPress? By default, WordPress search URLs are not user friendly. In this article, we will show you how to easily change the default search url slug in WordPress and make it more SEO and user friendly.
Why Change Default Search URL Slug in WordPress
WordPress uses SEO friendly URL structure for all pages on your website. Typical SEO friendly WordPress URLs look like this:
http://example.com/some-page/
http://example.com/2018/03/some-article/
http://example.com/category/some-category/
As you can see, these URLs are quite easy to understand for users as well as search engines.
However, WordPress still uses non-friendly URL for search results page. A typical search URL in WordPress looks like this:
http://example.com/?s=search-term
This URL structure doesnβt match the rest of your website URLs. While some WordPress search plugins improve the search results, most donβt do anything about the search URL itself.
What if you can make your search URL look like:
http://example.com/search/your-search-term/
Letβs take a look at how to make the WordPress search page URL slug more SEO friendly.
Changing Search Page URL Slug in WordPress
For this tutorial you will need to edit your WordPress theme files. If you havenβt done this before, then please take a look at our guide on how to copy and paste code in WordPress.
Method 1. Change WordPress Search URL Slug via Functions File
This method is easier and recommended for most users.
First, you need to copy and paste the following code in your themeβs file or a site-specific plugin:
Donβt forget to save your changes.
You can now go to your website and try using the search feature. You will notice that the search URL looks like this:
http://example.com/search/your-search-query/
Method 2. Change Search URL Slug via File
The is often used to set up redirects and other website configuration tasks. You can also use it to change the default search URL slug in WordPress.
Your file is located in your websiteβs root folder, and you will need to use FTP or File Manager app in cPanel to edit it. Refer to this guide, if you canβt find the file.
In your file, you need to paste the following code at the bottom:
Donβt forget to save your changes and upload the file back to the server.
You can now go to your website and use the search feature. You will notice the search URL will now look like this:
http://example.com/search/your-search-query/
We hope this article helped you change the default search URL slug in WordPress. You may also want to see our list of 55+ most wanted WordPress tips, tricks, and hacks.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.