如何在.htaccess中编写这个伪代码:
if (ip == "127.0.0.1") or (dns = "localhost") {
// all to http://
} else {
// all to https://
}
不久,需要本地的http和远程的https。谢谢。
你可以用这个:
RewriteEngine on
#if http host =127.0.0.1 or localhost
RewriteCond %{HTTP_HOST} ^127\.0\.0\.1$ [OR]
RewriteCond %{HTTP_HOST} ^localhost$
#then do nothing
RewriteRule ^ - [L]
#else enforce https
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]