I need to use SetEnvIf
in my .htaccess
file.
I also need to satisfy multiple conditions and then, show the required URL.
Here is my code:
SetEnvIf Remote_Host "^" press_flag=0
SetEnvIf Request_URI '/press/$' press_flag=1
SetEnvIf Cookie 'language\_uiAAAenglishBBB' press_flag=press_flag+1
SetEnvIf press_flag 2 Request_URI='Remote_Host/eng/test.html'
Explanation:
- In the first line, I am setting a variable
press_flag
to0
. - Second line, I check whether the URL ends with this text:
/press/
, if true, the I set the 'press_flag' to1
. - Third line, I check if the cookie matches
language\_uiAAAenglishBBB
text, if true, then I incrementpress_flag
value by 1. - Last line, I check if the
press_flag
value is 2, then I set theHTTP_HOST
accordingly.
But, when I open URL/press/
in browser, it is not getting redirected.
Please help to debug and fix this code.
Thanks.
HTTP_HOST
is the domain name, has nothing to do with the path segment of the URL. And I don’t see you doing any redirecting anywhere. – MacawHOST
– and if there was, HOST would still not mean “path”. – Macaw