I'm doing some reverse proxies for a blog and would like to achieve the following in my .htaccess file.
Redirect Legacy URLs
http://blog.domain.com/post-title-123.html
to
http://blog.domain.com/post-title/
I think I have to use the following piece of regex -[0-9]+.html to identify the part of the URL I wanted 'changing' to a /.
Any suggestions?
Try:
using mod_alias:
RedirectMatch 301 ^(.*)-[0-9]+\.html$ /$1/
or if you already are using mod_rewrite and don't want rewritten URI's to get mangled by mod_alias, stick with mod_rewrite and add this above any routing rules that you may have:
RewriteRule ^(.*)-[0-9]+\.html$ /$1/ [L,R=301]