问题
i'm currently forcing visitors to access all my websites (mostly Wordpress) over https, witch i do with the following code:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Now i was wondering if i can use an if is not statement, so if i work on my local environment, this won't work. For example:
<If "%{HTTP_HOST} != 'http://localhost:8888'">
# live configuration
</If>
<Else>
# local configuration
</Else>
What's the best way to do this? Thanks is advance!
回答1:
http:// is not part of match in {HTTP_HOST} variable .You need to use !='localhost' If you are testing the on a local host or !='example.com' If testing this on example.com .
Full code
<If "%{HTTP_HOST} != 'localhost'">
# live configuration
</If>
<Else>
# local configuration
</Else>
来源:https://stackoverflow.com/questions/50186811/if-is-not-localhost-statement-htaccess