I find apache very unfriendly.
Anyway. I have this:
RewriteRule (.*) - [QSA,E=DOMAIN_NAME:localhost.com]
This doesn't redirect, which is fine:
RewriteCond "www.%{ENV:DOMAIN_NAME}" "!=www.localhost.com"
RewriteRule ^ https://%{HTTP_HOST}?err=%{ENV:DOMAIN_NAME} [L,R=301]
This doesn't redirect, which is fine:
RewriteCond "%{HTTP_HOST}" "!=www.localhost.com"
RewriteRule ^ https://%{HTTP_HOST}?err=%{ENV:DOMAIN_NAME} [L,R=301]
This does redirect:
RewriteCond "www.%{ENV:DOMAIN_NAME}" "!=%{HTTP_HOST}"
RewriteRule ^ https://%{HTTP_HOST}?err=%{ENV:DOMAIN_NAME} [L,R=301]
Is very frustrating. I'm stuck in checking two variables if they match...
www.%{ENV:DOMAIN_NAME}
contains the same value as%{HTTP_HOST}