I'm building this real estate script using PHP and I want the listing page url's to be like /listing/this-is-the-title-436
. This url is generated in PHP and the last part of the url, after the last instance of ' - ' is the listing id. But I cannot find a way to find the last instance of a dash and use the rest as a variable in .htaccess.
Note that the title can have any amount of spaces therefore any amount of dashes but the listing id will always be at the end, after the last dash.
To summarize, I want urls like /listing/this-is-the-title-436
to redirect to /assets/inc/listing.php?listing=436
with .htaccess.
Any help would be appreciated, thanks!