-1

I'm migrating a huge site from an old proprietary CMS to WordPress and need to redirect the old URL structure.

The old system has all kinds of whacky URLs, but the one thing common to them all is that they contain a number which identifies the post, like this:

example.com/something/else/123456/another/thing.html
example.com/something/98765/thing.html
example.com/something/2468/.html

(The third one is not a typo!)

What htaccess rewrite rule will redirect any of these to a URL of the form example.com?oid=1234, where oid is the number extracted from the old URL?

So far I've come up with this, which is not working:

RewriteRule ^/.*([0-9]+)/.*\.html /?oid=$1

  • That page is useful, but I haven't worked out an answer to my specific question from it. – Simon Blackbourn Feb 23 '15 at 15:59
  • It's always a bit frustrating to see a reply to a canonical duplicate ala "Thanks, but I'm looking for instructions from New York to Washington for a blue ford explorer. I don't see any guidance there for a blue ford explorer". Your edit already does what you've asked btw, "is not working" is not helpful (doesn't work in what way?). – AD7six Feb 23 '15 at 17:04
  • @AD7six - it was giving me a 404 error. I've figured it out for myself, see answer below. – Simon Blackbourn Feb 23 '15 at 17:42

1 Answers1

1

I've worked it out after much trial and error:

RewriteRule ^(.+/)+([0-9]+)/.*\.html ?oid=$2