I need to do redirection if the values of 2 custom-defined environment variables are not identical.
Searching for any way to this on the web, or StackOverflow has been dismal .. been at it for hours now and found nothing that does this simple thing.
This is what I have so far, but it does not work, at all:
RewriteCond %{ENV:HREFBASE} !^$
RewriteCond %{ENV:PATHSTEM} !^%{ENV:HREFBASE}$
RewriteRule ^ %{REQUEST_SCHEME}://%{HTTP_HOST}/%{ENV:HREFBASE}%{REQUEST_URI} [R=302,L]
The part that is obviously wrong is this:
%{ENV:PATHSTEM} !^%{ENV:HREFBASE}$
I've tried several ways, but nothing seems to work.
Any input would we appreciated and rewarded in kind; thanks in advance.
UPDATE
I've even tried this:
RewriteCond %{ENV:HREFBASE} ^$
RewriteRule ^ - [L]
<If "%{ENV:PATHSTEM} != %{ENV:HREFBASE}">
RewriteRule ^ %{REQUEST_SCHEME}://%{HTTP_HOST}/%{ENV:HREFBASE}%{REQUEST_URI} [R=302,L]
</If>
I can see that the variables do not compare by catching a condition with PHP and printing out the entire $_SERVER array; the part that matters for this is:
[HREFBASE] => anon
[PATHSTEM] => Proc
-which shows clearly that they are not the same, but the redirect does not happen.