Redirect based on last numbers in url after the hyphen

By : Ian

I am trying to do the following redirect using .htaccess: to /index.php?id=12345

What would be the best regular expression to extract the digits after the last hyphen and a dot?

By : Ian


Perhaps the following:

RewriteRule ^.*-(\d )\.htm$ /index.php?id=$1

Untested, but see if that helps. This is based on my knowledge of RegEx, and the examples I found from various places.

There's also a helpful site that automates the process of .htaccess modifications, though I don't see anything pertaining to RegEx.

This video can help you solving your question :)
By: admin