Need help removing numbers from URL - redirecting

Greetings All,
Ok, so we are looking at moving our blog, which currently generates URLs similar to the following:

blog.example.com/bid/55555/title-of-article

This is going away,and our new URLs are going to be:

blog.example.com/title-of-article

However, I cannot seem to successfully remove the middle contents. Here is my current attempt at redirect:

RewriteRule ^bid/[0-9]+/(.*)$ /$1 [R=301/L]

I have tried LOTS of variations on this at this point, and can successfully remove either the bid portion OR the number, but not the entire portion of the string. Any thoughts on how to approach this?

Thanks!

The rule you posted looks okay to me and should work (provided you’re on Apache 2.x and the RewriteEngine is enabled). The only thing I see is that you used a / in the [L/R=301], that should be a comma: [L,R=301] (order of L and R=301 doesn’t matter, I just like it better when L is first; personal preference :))

Also, beware when testing 301 redirects that browsers will cache them, so if you test it, change the rule and then test it again it might be that the browser does what it did the first time because it’s cached that direct. It might than look as if the new rule doesn’t work.
The best way to overcome this is to first delete all browser cache (and restart the browser if you want to be really sure) and change 301 to 302 in the .htaccess, and then change it back to 301 once you’ve got it fully working :slight_smile: