The issue I have is that I need to match and replace a specific string in the URL, not splitting at the standard point of the querystring variables, and using only the second half of the the pagevars variable to be used in the intended URL.
In this particular case I need to use .htaccess to redirect this URL:
http://example.com/details.php?pagevars=this-variable-id-WGZ8765
to this: