https 支持已集成到Emlog 6.0,以下内容仅适用于Emlog 5.x用户。. }( m! q* W9 ?: s! `% F& X- X7 {
在进行修改之前,请先确定服务器已正确配置https。并且备份所有文件,防止遇到兼容性问题。
5 a1 M, `7 R+ Z1 {! X3 \% n
) t8 {4 ]! u- Z4 B 1. /include/lib/option.php
' [$ W: {: |5 A, ]) N 请将以下内容粘贴到 get function 的 default 判断分支之前 (在Emlog 5.3.1下是第43行)- case 'blogurl':& K. p" S- g$ I* a8 d
- return realUrl();
' P3 z( B$ }! s: s4 m. r# _ - break;
$ ]9 G V+ q1 P g' y
复制代码 2. /include/lib/function.base.php7 f* u& H# p6 a. ~
请将以下内容粘贴到文件的末尾- /**$ `( O" M3 t, p' n% k
- * 获取当前访问的base url9 [% r$ m) C5 p* }+ [
- */
6 y' Y* g. w5 a/ {( p* m( G - function realUrl() {# `5 h) Z, S: C: c
- $emlog_path = EMLOG_ROOT . DIRECTORY_SEPARATOR;
a( _- @; n. E. U' ]; j% b* Y6 | - $script_path = pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME);; y1 I( ~2 k6 Y" L, U! l3 {/ |
- $script_path = str_replace('\\', '/', $script_path);& |5 f1 u/ j W' H
- $path_element = explode('/', $script_path);6 F; Z+ I* s& i! F
-
/ c) N6 _; F7 ]1 _# x2 @ - $this_match = '';5 o+ Y: w" k9 V& A3 Q
- $best_match = '';: ?% r" {$ M/ F6 B& }
- 8 k. G. A9 x2 A9 P
- $current_deep = 0;3 i$ \/ n V5 V% R6 w7 B: g( c4 c
- $max_deep = count($path_element); _) R/ H1 C! \
- 4 S. t# X4 |! i. e4 q. H
- while($current_deep < $max_deep) {
( ?5 e# O2 a/ w: T# u, K - $this_match = $this_match . $path_element[$current_deep] . DIRECTORY_SEPARATOR;" w9 \; B& c3 _
- 0 Q" O6 n4 D" i+ Z, C Y+ A
- if (substr($emlog_path, strlen($this_match) * (-1)) === $this_match) {1 W4 u- d" X+ M2 ]' o
- $best_match = $this_match;2 j0 }! x' b b1 |9 W# w% ~! M# O7 b
- }
% k4 t9 l8 |$ c0 [ -
8 v0 r% g+ {4 J3 z W* A, d2 t. m - $current_deep++;- S* f. w4 L6 f
- }
3 c5 K- E; {4 |% e# O -
# a9 R4 f) P' r+ p6 X+ j0 o - $best_match = str_replace(DIRECTORY_SEPARATOR, '/', $best_match);4 ?! o* M& ]4 Z
- $real_url = $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
. E+ y d! x: ~ - $real_url .= $_SERVER["SERVER_NAME"];
7 s1 C6 V9 ]' C% }2 t - $real_url .= in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT'];
4 e6 Y6 ]2 ]* G' x; O; W! q - $real_url .= $best_match;
: ?" k8 |# A- |8 t -
1 ?8 f, E; [- K S1 t9 B - return $real_url;/ @# k6 W$ @3 A, z* x- z
- }
复制代码 4 x9 g, A0 c* W5 \% h
3. /init.php9 v* O+ b9 p; u8 ~6 b; Q5 ]6 R/ d$ y
请用以下代码覆盖同名的define (在Emlog 5.3.1下是第39行)
: y* F7 ~" q2 e+ G( p% F* m- define('DYNAMIC_BLOGURL', Option::get("blogurl"));
& s: _/ }) J9 [
* l. V+ U" I8 z) v6 y) Y8 C6 C5 y3 m3 x! N
9 ]" {1 X( i+ g# f; D1 e/ A# x' U$ ]6 s- o6 t' g6 D
|