Mod Rewrite Rule to take article ID from URL and place a Slash before it

I have a wordpress site which has hundreds of articles with URLs in the following format:

http://www.example.com/news/variable-article-name-XXXXXXXXX/

where XXXXXXXXX is always a 9 digit number

Read More

I’d like to rewrite the URLs to include a slash before the number; to appear as follows.

http://www.example.com/news/variable-article-name/XXXXXXXXX/

Is there a simple, single rule I can write to achieve this?

Any help appreciated.

Related posts

1 comment

  1. Try the following:

    RewriteRule ^news/(.*)-(d{9})/?$ /news/$1/$2 [R=301,L]
    

    You’d still need some internal rewrite so that the redirected URL can be forwarded to appropriate pages.

Comments are closed.