change wordpress search url – without 404 not found
-
Hi
i need a code to change wordpress search url fromhttps://localhost/wordpress/?s=daniel
to
https://localhost/wordpress/search/daniel
i have this code
function 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', 'change_search_url_rewrite' );
but when i search
<a href="">daniel</a>
the browser says 404 not found
this code has a .htaccess
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC] RewriteRule ^$ /search/%1/? [NC,R,L]
but it does’nt work
i make a .htaccess it my theme folder
- The topic ‘change wordpress search url – without 404 not found’ is closed to new replies.