首页 > 解决方案 > htaccess – FALSE If statement still runs

问题描述

I have an .htaccess file where I am using if statements to turn directives off/on for development and live environments. One used for forcing SSL in live environments works fine but one to control caching runs it's enclosed directives whether true or false.

<If "%{HTTP_HOST} != 'dev-domain.test'">        
    ExpiresActive On
    ExpiresDefault "access plus 0 seconds"
    ExpiresByType text/html "access plus 0 seconds"
</If>

I know the if logic works because I added a rewrite inside of it and commented out the other code and it worked when true and didn't redirect when false. I was using...

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 0 seconds"
    ExpiresByType text/html "access plus 0 seconds"
</IfModule>

which works but I tried the IF statement out of curiosity and it fails. Why is this?

标签: apache.htaccess

解决方案


推荐阅读