I'm using Apache mod_rewrite and I'm looking to dynamically set the Host
header with RequestHeader
based on the domain from the QUERY_STRING. How would I dynamically set the Host
?
Given the following request URL:
https://example.com/p12?url=http://nonssldomain.com/331551/1041505584.jpg?dt=032620151151
What I've tried:
RewriteCond %{QUERY_STRING} ^url=(.*)$ [NC]
#some regex to parse domain from Query_String (Doesn't work)
RequestHeader set Host ^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)
RewriteRule ^.*/p12$ %1? [P,NC,L]
Would I need to dynamically set a variable first?