CNC in WordPress search bar
Initially, if you type in the WordPress search bar query, we will get a link like:
https://wp-admin.com.ua/?s=wordpress&x=0&y=0
But you can easily convert the link like this:
https://wp-admin.com.ua/search/wordpress
First way CNC search:
function fb_change_search_url_rewrite() {
if ( is_search() && ! empty( $_GET['s'] ) ) {
wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
exit();
}
}
add_action( 'template_redirect', 'fb_change_search_url_rewrite' );The second way to CNC search through htaccess:
# search redirect
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
RewriteRule ^$ /search/%1/? [NC,R,L]The second way is more interesting and simple. Both methods work for me only with English.
See also the articleCNC Transliteration WordPress“.
/*

- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.




