How to set a custom header via .htaccess according to an environement variable using If/Else directive?
#Refresh-page
<If "%{ENV:DOCUMENT} == 'loading'">
Header set Refresh "3"
</If>
I am trying to use the syntax described in the documentation for Apache 2.4
http://httpd.apache.org/docs/2.4/mod/core.html#if
TEST 1
According to anubhava's answer
RewriteCond %{ENV:DOCUMENT} ^widget$
RewriteRule ^.* - [E=REFRESH:1]
#refresh page
Header set Refresh "3" env=REFRESH
RewriteCond %{ENV:REFRESH} ^1$
RewriteRule ^.* loading.html [L]
Alter your env variable to store 0 or 1 and then you can use Header set
like this:
You can use:
# set DOCUMENT=widget (remove if you are already setting this)
SetEnvIf Host ^ DOCUMENT=widget
# set isDoc=1 if DOCUMENT == widget
SetEnvIf DOCUMENT widget isDoc
# set header only if isDoc == 1
Header set Refresh "3" env=isDoc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With