Many people and wordpress developer want to remove the blog or category wordpress from URL. This is really good for seo also. Many times wordpress developer got requirement to remove the blog or category word from wordpress url.
In this tutorial I will let you know how can you easily achieve this requirement. There is two way to achieve this requirement. You can use the .htaccess file for fulfill this requirement.
Note: Apache mod_rewrite rule is must enable to with your Apache web server.
Open your .htaccess file which is present in your root folder of web hosting server. If not then create this file put it.
You can use the permanent redirect rewrite apache rule to achieve this. open your .htaccess file put following lines in that file
RewriteEngine On RewriteBase / #This rewrite rule we added for removing the category wordpress from URL RewriteRule ^category/(.+)$ http://www.wordpressapi.com/$1 [R=301,L] #This rewrite rule we added for removing the blog word wordpress from URL RewriteRule ^blog/(.+)$ http://www.wordpressapi.com/$1 [R=301,L]
You can achieve this by changing in the code also. Use the following code do this changes. Open your theme folder and functions.php file and put following code in that file.
function remove_blog_word($without_blog_word_permalink)
{
if(!preg_match("/^\/blog\//",$without_blog_word_permalink))
return $without_blog_word_permalink;
$new_permalink=preg_replace ("/^\/blog\//","/",$without_blog_word_permalink );
return $new_permalink;
}
function remove_category_word($without_category_word_permalink)
{
if(!preg_match("/^\/category\//",$without_category_word_permalink))
return $without_blog_word_permalink;
$new_permalink=preg_replace ("/^\/category\//","/",$without_category_word_permalink );
return $new_permalink;
}
add_filter("pre_update_option_permalink_structure","remove_blog_word");
add_filter("pre_update_option_permalink_structure","remove_category_word");
Just put above lines in your functions.php file and that will solve your issue.





I tried your solution you posted and I got
Parse error: syntax error, unexpected '}' in /home/content/n/e/r/nerec/html/wp-content/themes/lifestyle/functions.php on line 75
I removed your code and it did no good. Now my site is screwed..
Great information! I’ve been looking for something like this for a while now. Thanks!
Thanks for best news!
Just want to say what a great blog you got here!
I’ve been around for quite a lot of time, but finally decided to show my appreciation of your work!
Thumbs up, and keep it going!
Cheers
Christian, iwspo.net
Just want to say what a great blog you got here!
I’ve been around for quite a lot of time, but finally decided to show my appreciation of your work!
Thumbs up, and keep it going!
Cheers
Christian, iwspo.net
Just want to say what a great blog you got here!
I’ve been around for quite a lot of time, but finally decided to show my appreciation of your work!
Thumbs up, and keep it going!
Cheers
Christian,Earn Free Vouchers / Cash
Just want to say what a great blog you got here!
I’ve been around for quite a lot of time, but finally decided to show my appreciation of your work!
Thumbs up, and keep it going!
Cheers
Christian,Earn Free Vouchers / Cash
good !
Really good sharing this.