问题描述
我尝试在我的网站空间的子文件夹/子路径中安装 Lychee。 首先,我在本地笔记本电脑上尝试了这样的配置作为测试设置,然后我将它移到了我的网络空间。 虽然它在我的笔记本电脑上几乎立即开箱即用,但显然相同的配置会导致我的网络空间无限重定向循环。 我找不到区别。 :-(
如果我在浏览器 (https://www.mydomain.tld/lychee/
) 中打开 Lychee,我收到消息“服务器错误或未找到 API”,我可以看到 “500 - 内部服务器错误”回复https://www.my-domain.tld/lychee/PHP/index.PHP
的帖子请求。
服务器日志报告重写的无限递归。
我的笔记本电脑和我的网络空间之间最明显的区别是,我的笔记本电脑运行的 Apache 版本(vanilla 2.4.46)比我的提供商的网络服务器 (2.4.41-4ubuntu3.1) 上的版本稍新。
目录结构如下
/var/www
|
`-- my-domain # the web root of my domain
|
`-- lychee # the root of the Lychee app
|
`-- public # the public directory of Lychee which contains index.PHP
虚拟主机的 Apache 配置是
<VirtualHost *:443>
ServerName www.my-domain.tld
ServerAdmin admin@my-domain.tld
DocumentRoot /var/www/my-domain
Alias "/lychee" "/var/www/my-domain/lychee/public"
</VirtualHost>
我在本地计算机上测试了相同的目录结构和配置,其中 my-domain
替换为 localhost
,端口 80 而不是 443。
文件 /var/www/my-domain/lychee/.env
分别包含 APP_URL=https://www.my-domain.tld/lychee/
和 APP_URL=http://localhost/lychee/
,但其他方面完全相同。
我没有触及文件 /var/www/my-domain/lychee/public/.htaccess
并保留了上游版本。
因此,它在两台机器上是相同的:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.PHP [L]
</IfModule>
Options -Indexes
我的工作(本地)安装日志如下。 我添加了一些空行,以便将条目按逻辑分组,以简化并排比较,并帮助发现与非工作安装的差异。 我本地机器的访问日志:
127.0.0.1 "GET /lychee/ HTTP/1.1" 200 67262
127.0.0.1 "GET /lychee/dist/main.css?1608653869 HTTP/1.1" 304 -
127.0.0.1 "POST /lychee/PHP/index.PHP HTTP/1.1" 200 22585
我的空间访问日志:
172.16.42.12 "GET /lychee/ HTTP/1.1" 200 22499
172.16.42.12 "GET /lychee/dist/main.css?1609434024 HTTP/1.1" 200 15959
172.16.42.12 "POST /lychee/PHP/index.PHP HTTP/1.1" 500 886
我本地机器的错误日志(我加了行号):
1: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/ ->
2: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '.*' to uri ''
3: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/ ->
4: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri ''
5: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/ ->
6: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri ''
7: [trace1] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] pass through /var/www/localhost/lychee/public/
9: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.html -> index.html
10: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] applying pattern '.*' to uri 'index.html'
11: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.html -> index.html
12: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'index.html'
13: [trace2] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] rewrite 'index.html' -> 'index.PHP'
14: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] add per-dir prefix: index.PHP -> /var/www/localhost/lychee/public/index.PHP
16: [trace2] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] trying to replace context docroot /var/www/localhost/lychee/public with context prefix /lychee
18: [trace1] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] internal redirect with /lychee/index.PHP [INTERNAL REDIRECT]
19: [trace3] [rid#3/subreq] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.html.var -> index.html.var
20: [trace3] [rid#3/subreq] [perdir /var/www/localhost/lychee/public/] applying pattern '.*' to uri 'index.html.var'
21: [trace3] [rid#3/subreq] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.html.var -> index.html.var
22: [trace3] [rid#3/subreq] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'index.html.var'
23: [trace2] [rid#3/subreq] [perdir /var/www/localhost/lychee/public/] rewrite 'index.html.var' -> 'index.PHP'
24: [trace3] [rid#3/subreq] [perdir /var/www/localhost/lychee/public/] add per-dir prefix: index.PHP -> /var/www/localhost/lychee/public/index.PHP
26: [trace2] [rid#3/subreq] [perdir /var/www/localhost/lychee/public/] trying to replace context docroot /var/www/localhost/lychee/public with context prefix /lychee
38: [trace1] [rid#3/subreq] [perdir /var/www/localhost/lychee/public/] internal redirect with /lychee/index.PHP [INTERNAL REDIRECT]
39: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.PHP -> index.PHP
40: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] applying pattern '.*' to uri 'index.PHP'
41: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.PHP -> index.PHP
42: [trace3] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'index.PHP'
43: [trace1] [rid#2/subreq] [perdir /var/www/localhost/lychee/public/] pass through /var/www/localhost/lychee/public/index.PHP
49: [trace3] [rid#4/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/dist/main.css -> dist/main.css
50: [trace3] [rid#4/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '.*' to uri 'dist/main.css'
51: [trace3] [rid#4/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/dist/main.css -> dist/main.css
52: [trace3] [rid#4/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'dist/main.css'
53: [trace3] [rid#4/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/dist/main.css -> dist/main.css
54: [trace3] [rid#4/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'dist/main.css'
55: [trace1] [rid#4/initial] [perdir /var/www/localhost/lychee/public/] pass through /var/www/localhost/lychee/public/dist/main.css
61: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] add path info postfix: /var/www/localhost/lychee/public/PHP -> /var/www/localhost/lychee/public/PHP/index.PHP
62: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/PHP/index.PHP -> PHP/index.PHP
63: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '.*' to uri 'PHP/index.PHP'
64: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] add path info postfix: /var/www/localhost/lychee/public/PHP -> /var/www/localhost/lychee/public/PHP/index.PHP
65: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/PHP/index.PHP -> PHP/index.PHP
66: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'PHP/index.PHP'
67: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] add path info postfix: /var/www/localhost/lychee/public/PHP -> /var/www/localhost/lychee/public/PHP/index.PHP
68: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/PHP/index.PHP -> PHP/index.PHP
69: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'PHP/index.PHP'
70: [trace2] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] rewrite 'PHP/index.PHP' -> 'index.PHP'
71: [trace3] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] add per-dir prefix: index.PHP -> /var/www/localhost/lychee/public/index.PHP
73: [trace2] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] trying to replace context docroot /var/www/localhost/lychee/public with context prefix /lychee
74: [trace1] [rid#1/initial] [perdir /var/www/localhost/lychee/public/] internal redirect with /lychee/index.PHP [INTERNAL REDIRECT]
77: [trace3] [rid#6/initial/redir#1] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.PHP -> index.PHP
78: [trace3] [rid#6/initial/redir#1] [perdir /var/www/localhost/lychee/public/] applying pattern '.*' to uri 'index.PHP'
80: [trace3] [rid#6/initial/redir#1] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.PHP -> index.PHP
81: [trace3] [rid#6/initial/redir#1] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'index.PHP'
83: [trace3] [rid#6/initial/redir#1] [perdir /var/www/localhost/lychee/public/] strip per-dir prefix: /var/www/localhost/lychee/public/index.PHP -> index.PHP
84: [trace3] [rid#6/initial/redir#1] [perdir /var/www/localhost/lychee/public/] applying pattern '^' to uri 'index.PHP'
85: [trace1] [rid#6/initial/redir#1] [perdir /var/www/localhost/lychee/public/] pass through /var/www/localhost/lychee/public/index.PHP
1: [trace3] [rid#01/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/ ->
2: [trace3] [rid#01/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '.*' to uri ''
3: [trace3] [rid#01/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/ ->
4: [trace3] [rid#01/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri ''
5: [trace3] [rid#01/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/ ->
6: [trace3] [rid#01/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri ''
7: [trace1] [rid#01/initial] [perdir /var/www/my-domain/lychee/public/] pass through /var/www/my-domain/lychee/public/
9: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/index.html -> index.html
10: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] applying pattern '.*' to uri 'index.html'
11: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/index.html -> index.html
12: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'index.html'
13: [trace2] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] rewrite 'index.html' -> 'index.PHP'
14: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] add per-dir prefix: index.PHP -> /var/www/my-domain/lychee/public/index.PHP
16: [trace2] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] strip document_root prefix: /var/www/my-domain/lychee/public/index.PHP -> /lychee/public/index.PHP
18: [trace1] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] internal redirect with /lychee/public/index.PHP [INTERNAL REDIRECT]
19: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/index.cgi -> index.cgi
20: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] applying pattern '.*' to uri 'index.cgi'
21: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/index.cgi -> index.cgi
22: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'index.cgi'
23: [trace2] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] rewrite 'index.cgi' -> 'index.PHP'
24: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] add per-dir prefix: index.PHP -> /var/www/my-domain/lychee/public/index.PHP
26: [trace2] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] strip document_root prefix: /var/www/my-domain/lychee/public/index.PHP -> /lychee/public/index.PHP
28: [trace1] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] internal redirect with /lychee/public/index.PHP [INTERNAL REDIRECT]
29: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/index.pl -> index.pl
30: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] applying pattern '.*' to uri 'index.pl'
31: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/index.pl -> index.pl
32: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'index.pl'
33: [trace2] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] rewrite 'index.pl' -> 'index.PHP'
34: [trace3] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] add per-dir prefix: index.PHP -> /var/www/my-domain/lychee/public/index.PHP
36: [trace2] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] strip document_root prefix: /var/www/my-domain/lychee/public/index.PHP -> /lychee/public/index.PHP
38: [trace1] [rid#02/subreq] [perdir /var/www/my-domain/lychee/public/] internal redirect with /lychee/public/index.PHP [INTERNAL REDIRECT]
39: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/index.PHP -> index.PHP
40: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] applying pattern '.*' to uri 'index.PHP'
41: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/index.PHP -> index.PHP
42: [trace3] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'index.PHP'
43: [trace1] [rid#03/subreq] [perdir /var/www/my-domain/lychee/public/] pass through /var/www/my-domain/lychee/public/index.PHP
49: [trace3] [rid#04/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/dist/main.css -> dist/main.css
50: [trace3] [rid#04/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '.*' to uri 'dist/main.css'
51: [trace3] [rid#04/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/dist/main.css -> dist/main.css
52: [trace3] [rid#04/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'dist/main.css'
53: [trace3] [rid#04/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/dist/main.css -> dist/main.css
54: [trace3] [rid#04/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'dist/main.css'
55: [trace1] [rid#04/initial] [perdir /var/www/my-domain/lychee/public/] pass through /var/www/my-domain/lychee/public/dist/main.css
61: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] add path info postfix: /var/www/my-domain/lychee/public/PHP -> /var/www/my-domain/lychee/public/PHP/index.PHP
62: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/PHP/index.PHP -> PHP/index.PHP
63: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '.*' to uri 'PHP/index.PHP'
64: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] add path info postfix: /var/www/my-domain/lychee/public/PHP -> /var/www/my-domain/lychee/public/PHP/index.PHP
65: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/PHP/index.PHP -> PHP/index.PHP
66: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'PHP/index.PHP'
67: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] add path info postfix: /var/www/my-domain/lychee/public/PHP -> /var/www/my-domain/lychee/public/PHP/index.PHP
68: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/PHP/index.PHP -> PHP/index.PHP
69: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'PHP/index.PHP'
70: [trace2] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] rewrite 'PHP/index.PHP' -> 'index.PHP'
71: [trace3] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] add per-dir prefix: index.PHP -> /var/www/my-domain/lychee/public/index.PHP
73: [trace2] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] strip document_root prefix: /var/www/my-domain/lychee/public/index.PHP -> /lychee/public/index.PHP
74: [trace1] [rid#02/initial] [perdir /var/www/my-domain/lychee/public/] internal redirect with /lychee/public/index.PHP [INTERNAL REDIRECT]
75: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] add path info postfix: /var/www/my-domain/lychee/public/public -> /var/www/my-domain/lychee/public/public/index.PHP
77: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/public/index.PHP -> public/index.PHP
78: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] applying pattern '.*' to uri 'public/index.PHP'
79: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] add path info postfix: /var/www/my-domain/lychee/public/public -> /var/www/my-domain/lychee/public/public/index.PHP
80: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/public/index.PHP -> public/index.PHP
81: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'public/index.PHP'
82: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] add path info postfix: /var/www/my-domain/lychee/public/public -> /var/www/my-domain/lychee/public/public/index.PHP
83: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] strip per-dir prefix: /var/www/my-domain/lychee/public/public/index.PHP -> public/index.PHP
84: [trace3] [rid#06/initial/redir#01] [perdir /var/www/my-domain/lychee/public/] applying pattern '^' to uri 'public/index.PHP'
... infinite loop starts here ...
明显的初始差异在第 16、26、36 和 73 行。 工作配置的日志包含
trying to replace context docroot /var/www/localhost/lychee/public with context prefix /lychee
而非工作配置的日志包含
strip document_root prefix: /var/www/my-domain/lychee/public/index.PHP -> /lychee/public/index.PHP
尽管文本部分的措辞不同,/public/
部分仍保留在路径中。
这最终导致我的网络空间无限递归(比较第 77 行以后的日志)。
虽然工作配置日志的第 85 行最终指出
pass through /var/www/localhost/lychee/public/index.PHP
以下几行在我的生产日志中无限重复
strip per-dir prefix: /var/www/my-domain/lychee/public/public/index.PHP -> public/index.PHP
applying pattern '.*' to uri 'public/index.PHP'
add path info postfix: /var/www/my-domain/lychee/public/public -> /var/www/my-domain/lychee/public/public/index.PHP
造成这种差异的原因是什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)