<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>base_url &#8211; 這世上 沒有偶然 只有必然</title>
	<atom:link href="https://wordpress.lokidea.com/tag/base_url/feed/" rel="self" type="application/rss+xml" />
	<link>https://wordpress.lokidea.com</link>
	<description>幻幽的小小分享區</description>
	<lastBuildDate>Thu, 20 Apr 2017 12:48:13 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>PHP判斷http或https的連線</title>
		<link>https://wordpress.lokidea.com/1575/php%e5%88%a4%e6%96%b7http%e6%88%96https%e7%9a%84%e9%80%a3%e7%b7%9a/</link>
					<comments>https://wordpress.lokidea.com/1575/php%e5%88%a4%e6%96%b7http%e6%88%96https%e7%9a%84%e9%80%a3%e7%b7%9a/#respond</comments>
		
		<dc:creator><![CDATA[Barney Chen]]></dc:creator>
		<pubDate>Thu, 20 Apr 2017 12:48:13 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[偶然]]></category>
		<category><![CDATA[base_url]]></category>
		<category><![CDATA[codeigniter]]></category>
		<guid isPermaLink="false">https://wordpress.lokidea.com/?p=1575</guid>

					<description><![CDATA[Codeigniter 的 base_url 要弄成判斷 http 或是 https 真麻煩 今天找語法就找了 &#8230; <a href="https://wordpress.lokidea.com/1575/php%e5%88%a4%e6%96%b7http%e6%88%96https%e7%9a%84%e9%80%a3%e7%b7%9a/" class="more-link">閱讀全文 <span class="screen-reader-text">PHP判斷http或https的連線</span></a>]]></description>
										<content:encoded><![CDATA[<p>Codeigniter 的 base_url 要弄成判斷 http 或是 https 真麻煩<br />
今天找語法就找了四個版本<br />
一開始找到的版本不知道為何都不生效<br />
今天只想先記錄一下，下次再來研究到底為什麼會這樣<br />
SSL也不是買憑證唷，是用cloudflare提供的<br />
<span id="more-1575"></span></p>
<blockquote>
<hr />
<p>版本一：$root = ($_SERVER[&#8216;SERVER_PORT&#8217;] == 443 ? &#8216;https&#8217; : &#8216;http&#8217;);</p>
<hr />
<p>版本二：$root = &#8220;http&#8221;.((isset($_SERVER[&#8216;HTTPS&#8217;]) &amp;&amp; $_SERVER[&#8216;HTTPS&#8217;] == &#8220;on&#8221;) ? &#8220;s&#8221; : &#8220;&#8221;);</p>
<hr />
<p>版本三：$root = (empty($_SERVER[&#8216;HTTPS&#8217;]) OR strtolower($_SERVER[&#8216;HTTPS&#8217;]) === &#8216;off&#8217;) ? &#8216;http&#8217; : &#8216;https&#8217;;</p></blockquote>
<hr />
<blockquote><p>版本四：<br />
$isSecure = false;<br />
if (isset($_SERVER[&#8216;HTTPS&#8217;]) &amp;&amp; $_SERVER[&#8216;HTTPS&#8217;] == &#8216;on&#8217;) {<br />
$isSecure = true;<br />
}<br />
elseif (!empty($_SERVER[&#8216;HTTP_X_FORWARDED_PROTO&#8217;]) &amp;&amp; $_SERVER[&#8216;HTTP_X_FORWARDED_PROTO&#8217;] == &#8216;https&#8217; || !empty($_SERVER[&#8216;HTTP_X_FORWARDED_SSL&#8217;]) &amp;&amp; $_SERVER[&#8216;HTTP_X_FORWARDED_SSL&#8217;] == &#8216;on&#8217;) {<br />
$isSecure = true;<br />
}<br />
$root = $isSecure ? &#8216;https&#8217; : &#8216;http&#8217;;</p></blockquote>
<p>&nbsp;</p>
<hr />
<p>我也放了一份在 <a href="https://gist.github.com/Barneybook/6bc0a9a6e6056b08d89553648ef12dd3" target="_blank" rel="noopener noreferrer">gist上面</a> 唷<br />
下一篇應該就會解釋這四種方法為什麼可以用，為什麼不能用了</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wordpress.lokidea.com/1575/php%e5%88%a4%e6%96%b7http%e6%88%96https%e7%9a%84%e9%80%a3%e7%b7%9a/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
