{"id":4605,"date":"2016-09-05T08:40:50","date_gmt":"2016-09-05T00:40:50","guid":{"rendered":"https:\/\/www.icocean.com\/blog\/?p=4605"},"modified":"2016-09-05T08:40:50","modified_gmt":"2016-09-05T00:40:50","slug":"%e4%b8%baemlog-5-x%e6%b7%bb%e5%8a%a0https%e6%94%af%e6%8c%81","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=4605","title":{"rendered":"\u4e3aemlog 5.x\u6dfb\u52a0https\u652f\u6301"},"content":{"rendered":"<p>https \u652f\u6301\u5df2\u96c6\u6210\u5230Emlog 6.0\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9002\u7528\u4e8eEmlog 5.x\u7528\u6237\u3002<br \/>\n\u5728\u8fdb\u884c\u4fee\u6539\u4e4b\u524d\uff0c\u8bf7\u5148\u786e\u5b9a\u670d\u52a1\u5668\u5df2\u6b63\u786e\u914d\u7f6ehttps\u3002\u5e76\u4e14\u5907\u4efd\u6240\u6709\u6587\u4ef6\uff0c\u9632\u6b62\u9047\u5230\u517c\u5bb9\u6027\u95ee\u9898\u3002<!--more--><\/p>\n<p>1. \/include\/lib\/option.php<br \/>\n\u8bf7\u5c06\u4ee5\u4e0b\u5185\u5bb9\u7c98\u8d34\u5230 get function \u7684 default \u5224\u65ad\u5206\u652f\u4e4b\u524d \uff08\u5728Emlog 5.3.1\u4e0b\u662f\u7b2c43\u884c\uff09<br \/>\n<code>    case 'blogurl':<br \/>\n        return realUrl();<br \/>\n        break;<\/code><\/p>\n<p>2. \/include\/lib\/function.base.php<br \/>\n\u8bf7\u5c06\u4ee5\u4e0b\u5185\u5bb9\u7c98\u8d34\u5230\u6587\u4ef6\u7684\u672b\u5c3e<br \/>\n<code>    \/**<br \/>\n     * \u83b7\u53d6\u5f53\u524d\u8bbf\u95ee\u7684base url<br \/>\n     *\/<br \/>\n    function realUrl() {<br \/>\n        static $real_url = NULL;<\/p>\n<p>        if ($real_url !== NULL) {<br \/>\n            return $real_url;<br \/>\n        }<\/p>\n<p>        $emlog_path = EMLOG_ROOT . DIRECTORY_SEPARATOR;<br \/>\n        $script_path = pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME);<br \/>\n        $script_path = str_replace('\\\\', '\/', $script_path);<br \/>\n        $path_element = explode('\/', $script_path);<\/p>\n<p>        $this_match = '';<br \/>\n        $best_match = '';<\/p>\n<p>        $current_deep = 0;<br \/>\n        $max_deep = count($path_element);<\/p>\n<p>        while($current_deep < $max_deep) {\n            $this_match = $this_match . $path_element[$current_deep] . DIRECTORY_SEPARATOR;\n            \n            if (substr($emlog_path, strlen($this_match) * (-1)) === $this_match) {\n                $best_match = $this_match;\n            }\n            \n            $current_deep++;\n        }\n        \n        $best_match = str_replace(DIRECTORY_SEPARATOR, '\/', $best_match);\n        $real_url  = $_SERVER['HTTPS'] === 'on' ? 'https:\/\/' : 'http:\/\/';\n        $real_url .= $_SERVER[\"SERVER_NAME\"];\n        $real_url .= in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT'];\n        $real_url .= $best_match;\n        \n        return $real_url;\n    }<\/code><\/p>\n<p>3. \/init.php<br \/>\n\u8bf7\u7528\u4ee5\u4e0b\u4ee3\u7801\u8986\u76d6\u540c\u540d\u7684define \uff08\u5728Emlog 5.3.1\u4e0b\u662f\u7b2c39\u884c\uff09<br \/>\n    <\/code><code>define('DYNAMIC_BLOGURL', Option::get(\"blogurl\"));<\/code><br \/>\n\u8bd5\u8bd5\u7528HTTPS\u94fe\u63a5\u8bbf\u95ee\u8fd9\u7bc7\u6587\u7ae0\u5427\uff1ahttps:\/\/vsean.net\/blog\/post\/196<\/p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fEmlog 5.3.1\uff0c\u5e76\u4e14\u6ca1\u6709\u5bf9\u6e90\u4ee3\u7801\u505a\u8fc7\u4fee\u6539\uff0c\u4e5f\u53ef\u4ee5\u4e0b\u8f7d\u9644\u4ef6\u91cc\u7684\u6587\u4ef6\u76f4\u63a5\u8986\u76d6\u540c\u540d\u6587\u4ef6<\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/vsean.net\/blog\/content\/uploadfile\/201412\/70421419471066.zip\" target=\"_blank\">emlog_https.zip<\/a> <\/p>\n<p>\u6765\u6e90:https:\/\/blog.vsean.net\/post\/196<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https \u652f\u6301\u5df2\u96c6\u6210\u5230Emlog 6.0\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9002\u7528\u4e8eEmlog 5.x\u7528\u6237\u3002 \u5728\u8fdb\u884c\u4fee\u6539\u4e4b\u524d\uff0c\u8bf7\u5148\u786e\u5b9a <a href='https:\/\/www.icocean.com\/blog\/?p=4605' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-4605","post","type-post","status-publish","format-standard","hentry","category-4","category-4-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4605","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4605"}],"version-history":[{"count":1,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4605\/revisions"}],"predecessor-version":[{"id":4606,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4605\/revisions\/4606"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}