Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  DirectAdmin  >  How to Change a WordPress Site’s Search URL Slug via DirectAdmin?
Top Scroll

How to Change a WordPress Site’s Search URL Slug via DirectAdmin?

 3 min

SEO-friendly URLs are beneficial for indexing but that is all there is to it. The secret to advance the search engine ranking lies in the platform’s default search website structure and URL hosting. With DirectAdmin, users can improve the search URL slug of any WordPress site ( to raise its overall SEO status.

With a few adjustments, your search URL slugs will be more in tune with your site’s permalinks format. We have talked about configuring the Functions File and changing the .htaccess file. The idea is to change the site’s present search URL slug: into this

Table of Contents

Did you know!

Configuring your WordPress website with SEO-friendly URLs will only index posts and pages which, is not enough to improve SEO ranking. The structure of these search URLs should also seem genuine and easy to read for search engine crawlers to optimize the search pages for search engines.

Rearrange Site’s Function File

1. Log in to your user account of DirectAdmin.

2. Go to the System Info & Files section and click on File Manager.

The File Manager interface will open.

3. Browse functions.php file by following the path public_html>>wp-content >> themes.

4. Right-click the functions.php file and select Edit.

The file will open in the editor window.

5. Paste the given code at the end of the file.

* Change search page slug.

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

6. Click SAVE and close the editor.

It should change the structure of the search URL slug to the most optimum level.

Improve Search URL Slug with .htaccess

1. Log in to your DirectAdmin account.

2. Open File Manager and edit the .htaccess file.

Note: You can refer to this article to help you understand How to Create/Edit .htaccess File via DirectAdmin?

3. Paste this code at the end of the file:

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

4. Click SAVE and close the editor.

DirectAdmin users can use any one of the methods and amend the search URL slug of a WordPress site, improving its SEO.


Users can also use the FTP client to download the functions.php or .htaccess file, edit and then reupload them on the server.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.