QuestionsCategory: General QuestionRemove sub-directories from URL by Apache mod_rewrite
asked 2 years ago
I’m managing an instance of WordPress where the URLs are in the following format:

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 “uncategorised”.
I can easily change WordPress to render the URL without the category name (e.g.,, but I’d like to create a mod_rewrite rule to automatically redirect any requests for the previous format to the new, cleaner one.
How can I use a 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?

replied 55 mins ago

Hi! I just wish to offer you a huge thumbs
up for your great info you’ve got right here
on this post. I am returning to your site for more soon.

My web page :: снять место для хранения вещей

replied 8 seconds ago

Spot on with this write-up, I truly believe that this amazing site
needs much more attention. I’ll probably be back again to read
more, thanks for the information!

Also visit my site; хранение вещей в минске

1 Answers
tech Staff
answered 2 years ago
Something as simple as:

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

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

Your Answer