If you are running WordPress 2.3 and you converted your categories to tags then you have a problem. You have created a ton of 404 errors for your visitors. Your visitors cannot find the posts and they will leave, frustrated.
After I converted over to 2.3 I noticed hits on the blog for /category/[something] that no longer exist. Sending users to the theme’s 404 page. I wanted to find a solution that didn’t involve editing the 404 page telling visitors to search the site. So I searched found a solution ((I’ll add a link when I get back inside)) on another blog on Huddled Masses blog. The code I found is for your .htaccess file. If you don’t have access to edit your .htaccess then you can’t use this hack.
I incorporated the changes and it works very well. The stock code I copied didn’t allow for the calling of in-use, not converted, or new categories. I modified the code. This modification allows the use of your current categories while changing all of the remaining /category/[something] to /tag/[something] and making it a 301 (permanent) redirect so that search engines will index the site correctly.
Stay tuned here for the code to add to your .htaccess file. I’ll have it added shortly today, maybe as long as an hour.
Here is the code from the site. -
# Keep this out of the wordpress section, or it will get overwritten
RewriteEngine On
RewriteBase /
# rewrite categories as tags
RewriteRule ^category/(.+)$ tag/$1 [redirect=permanent,last]
# rewrite posts by my nick to my new /%postname%/ permalinks
RewriteRule ^jaykul/(.+)$ $1 [redirect=permanent,last]
# rewrite up to four levels of nested categories as tag intersections
# But don’t forget to allow access to the feeds
RewriteRule ^tag/([^/+,]+)/(?!feed|RSS (Really Simple Syndication)|rss2|atom)([^/+,]+)/?$ tag/$1+$2/ [redirect=permanent,last]
RewriteRule ^tag/([^/+,]+)/([^/+]+)/(feed|rss|rss2|atom)/?$ tag/$1+$2/$3 [redirect=permanent,last]
RewriteRule ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/?$ tag/$1+$2+$3/ [redirect=permanent,last]
RewriteRule ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/(feed|rss|rss2|atom)/?$ tag/$1+$2+$3/$4 [redirect=permanent,last]
RewriteRule ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/([^/]*)/?$ tag/$1+$2+$3+$4/ [redirect=permanent,last]
Here is the code as I modified it. -
# Keep this out of the wordpress section, or it will get overwritten
RewriteEngine On
RewriteBase /
# Exclude in use categories
RewriteCond %{REQUEST_URI} !^/category/uncategorized/$ [NC]
RewriteCond %{REQUEST_URI} !^/category/featured/$ [NC]
RewriteCond %{REQUEST_URI} !^/category/asides/$ [NC]
# rewrite categories as tags
RewriteRule ^category/(.+)$ tag/$1 [R=301,L]
Great information! I’ll be sure to let me WP tech support people know. Oh wait, you are my WP tech support people!
Comment by Dayngr — October 24, 2007 @ 2:53 PM