https 支持已集成到Emlog 6.0,以下内容仅适用于Emlog 5.x用户。
) o6 i. }' C9 i% F0 z0 R 在进行修改之前,请先确定服务器已正确配置https。并且备份所有文件,防止遇到兼容性问题。
' e1 G5 m& |0 U; c
3 K5 H7 f9 _, o0 b' e* X, t; n 1. /include/lib/option.php
) s- A, S3 ~# V7 h4 i9 z 请将以下内容粘贴到 get function 的 default 判断分支之前 (在Emlog 5.3.1下是第43行)- case 'blogurl':- W' b1 H+ X& h, _; H, \
- return realUrl();
0 G- A) K. [8 i) ` - break;9 H: E+ O0 [, r$ L0 w4 h" ~+ t
复制代码 2. /include/lib/function.base.php
* g0 g- s, R$ w 请将以下内容粘贴到文件的末尾- /**& B) D- y+ K& ^
- * 获取当前访问的base url/ {; M; Q: C* d* ^5 w+ g0 v' q- Z0 ]
- */7 Y* G, \0 z! R+ e
- function realUrl() {
8 L6 l' }6 S& i8 K1 Z3 L& ~ - $emlog_path = EMLOG_ROOT . DIRECTORY_SEPARATOR;
( Y* e' s5 H5 o7 Q5 [ - $script_path = pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME);3 A; @% D( ^% S |& ~$ V
- $script_path = str_replace('\\', '/', $script_path);5 E! ?2 s) |. v) [0 x; O
- $path_element = explode('/', $script_path);
+ ]% t" A2 n; Y* C1 e% C -
2 c+ T A0 W8 Y# d2 C% t - $this_match = '';
8 t2 X! b6 T6 q) h7 }# S - $best_match = '';! }; c6 O6 E/ P" H: A
-
: {& p4 H/ X0 h8 M - $current_deep = 0;
3 W+ y" P6 g3 b, t - $max_deep = count($path_element);6 x# j! z& @3 C! H$ K
- " [, C# b4 M7 y4 }: c
- while($current_deep < $max_deep) {) y ~6 C0 g( f v, r3 x
- $this_match = $this_match . $path_element[$current_deep] . DIRECTORY_SEPARATOR;8 i& O+ z9 R: u9 x% W7 Z8 W. o
- 8 m) }% C9 a" F4 y! y/ W* N+ q) A
- if (substr($emlog_path, strlen($this_match) * (-1)) === $this_match) {
& A) M7 D# q6 u" I; P: m - $best_match = $this_match;
& ~0 a; x5 `1 s* n$ u; k - }
/ E. X! j1 r- }# K, b - , j) }9 K0 W: v7 ~$ a, N
- $current_deep++;9 W$ W+ W( D6 l1 b. W
- }
6 B9 D$ ~4 }! C9 e" X0 f - ) l, [2 e+ V' h) o% }
- $best_match = str_replace(DIRECTORY_SEPARATOR, '/', $best_match);
9 b. Q E& [# t% X - $real_url = $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';4 Z% W5 O7 g, [3 S- k {2 {9 j
- $real_url .= $_SERVER["SERVER_NAME"];
8 B5 X* c; o5 Q( ?1 n+ O3 O - $real_url .= in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT'];
; Z9 ~5 h$ b; n+ Z/ S' X' b - $real_url .= $best_match;
8 `3 x- D$ @2 O- {9 I7 C. |- ` - * g, T; l7 i% _' [2 W5 ` l d5 t
- return $real_url; w; _' w# N8 G
- }
复制代码
. J( ?- |% N- A) k) N/ G 3. /init.php. J) d2 [+ B% _ ]
请用以下代码覆盖同名的define (在Emlog 5.3.1下是第39行)
# f' m/ A1 d5 ?& W& x( R" @- define('DYNAMIC_BLOGURL', Option::get("blogurl"));
2 m8 `: S/ o/ ~ @% `" P ( Z; J& z8 } Z( T' b: N9 X
1 G [, [! J& n" v3 C- D7 B% K2 h; O/ r* }* l8 H
6 j5 J4 f$ e0 a1 \: M
|