<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[PHP实现强制http跳转到https]]></title><description><![CDATA[<p dir="auto">网站升级了https，但是很多用户还是在访问http，容易导致数据不安全等问题。<br />
如何实现强制跳转https？非常简单，几行代码即可。<br />
将下面的代码加在页面还没有任何输出的地方，注意是没有任何输出，否则会出错！</p>
<pre><code>if($_SERVER["SERVER_PORT"] != "443"){
    Header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
}
</code></pre>
<p dir="auto">这样就可以实现https强制跳转了，如果你的https不是443端口，请自行修改。</p>
]]></description><link>https://node.zuimc.hiwbb.com/topic/27453/php实现强制http跳转到https</link><generator>RSS for Node</generator><lastBuildDate>Mon, 30 Nov 2026 15:44:33 GMT</lastBuildDate><atom:link href="https://node.zuimc.hiwbb.com/topic/27453.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Aug 2017 16:15:49 GMT</pubDate><ttl>60</ttl></channel></rss>