---
description: >-
  https://www.wpbeginner.com/wp-tutorials/how-to-change-the-default-search-url-slug-in-wordpress/
---

# How to Change the Default Search URL Slug in WordPress (ok)

![](https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MRAT7p4RlwtkPESSda6%2F-MRAUpWjqP2nsl3rv8b2%2FScreenshot_3.jpg?alt=media\&token=bdd38018-be1d-4fe0-b83b-7ec80f3b1014)

![](https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MRAT7p4RlwtkPESSda6%2F-MRAUtuw3t4xdEbShB-G%2FScreenshot_4.jpg?alt=media\&token=3956ba7b-15fa-483f-93f0-6483c3108227)

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

Hoặc

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

&#x20;[.htaccess file](https://www.wpbeginner.com/beginners-guide/why-you-cant-find-htaccess-file-on-your-wordpress-site/)



