<script type="text/javascript">var targetProtocol = "https:";if (window.location.protocol != targetProtocol) window.location.href = targetProtocol +window.location.href.substring(window.location.protocol.length);</script>用了这段代码,如果用户访问了如http://leonax.net/…,会被重定向到https://leonax.net/…..。如果想反过来,即把HTTPS强制重定向到HTTP,把targetProtocol的值改成http就行。是不是很方便?