Blogjak


Percayalah anda bisa. Anda sudah setengah jalan. - Theodore Roosevelt

What's New?


Change Wordpress Search URL To Be SEO Friendly

Wordpress Search Seo FriendlyIt is important thing to know that you only use readable Url. If human can't read or understand your Urls, either can search engines! A wordpress search is the syntax ?s as default. It is not good for SEO URL optimization. How does it work?

Even you have been activated permalink as post name, but you can not set the search URL in your dashboard setting. You need insert a bit of code and let it redirect another folder.

First step, you open cpanel and find a page name function.php and insert this code.

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' );

 And then let it redirect to another folder name "search" in htaccess. Here is the code

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


Now you can type in your browser as http://yourdomain.com/search/seo