views:

608

answers:

1

I'm managing an instance of Wordpress where the URLs are in the following format:

http://www.example.com/example-category/blog-post-permalink/

The blog author did an inconsistent job of adding categories to posts, so while some of them had legitimate categories in their URLS, at least half are "uncategorized".

I can easily change Wordpress to render the URL w/o the category name (e.g., http://www.example.com/blog-post-permalink/), but I'd like to create a mod_rewrite rule to automatically redirect any requests for the previous format to the new, cleaner one.

Do you have a good mod_rewrite recipe to handle this, taking into account that I want to honor requests for the real WordPress directories that are in my webroot?

+2  A: 

Something as simple as

 RewriteRule ^/[^/]+/([^/]+)/?$ /$2 [R]

Perhaps would do it? That simple redirects /foo/bar/ to /bar

Paul Dixon
That seems to work great with my testing so far. Thanks for the help!
berberich