gpt4 book ai didi

nginx - 带有 Nginx 的 Moodle 2.3 vs 斜杠参数重写

转载 作者:行者123 更新时间:2023-12-04 02:26:31 30 4
gpt4 key购买 nike

我正在尝试使用 nginx 最新版本设置 Moodle 2.3(不是 2.5)版本。之前在这个网站上有一些建议。其中之一:Moodle 2.0 with Nginx backend .

显然,正如任何人所知,Moodle 正在使用 path_info 规则来发布这样的 URL:http://example.com/moodle/pluginfile.php/26/mod_scorm/content/1/index.html .为了摆脱所有这些噩梦,Moodle 提议在 UI 中禁用“斜线参数”。这很棒。但不适用于 SCORM 播放器,尽管有先前的选项,但它仍强制使用“斜线参数”。因此,禁用“斜线参数”后,一切正常。但我唯一的目标是使用SCORM播放器。

我尝试使用上面链接中的重写规则:

rewrite ^(.*\.php)(/)(.*)$ $1?file=/$3 last;

这在 2.3-2.5 版本中不起作用。我认为它在 1.9 中有效。
现在 Moodle 使用不同的路径:

http://example.com/moodle/pluginfile.php/26/mod_scorm/content/1/index.html

一些 nginx 规则:
location ^~ /moodle {
location ~* ^.+\.(?:css|js|htc|xml|jpe?g|gif|png|ico|bmp|svg|swf|pdf|docx?|xlsx?|tiff?|txt|rtf|cgi|bat|pl|dll|aspx?|class|otf|ttf|woff|eot|less)$ {
add_header Access-Control-Allow-Origin *;
access_log off;
expires 30d;
tcp_nodelay off;
try_files $uri =404;
}
location ~* ^/moodle/.*\.php$ {
include includes/fastcgi_params.conf;
try_files $uri @dynamic;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_read_timeout 1200;
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9090;

}
rewrite (^.*\.php)(/.*) $1 last;
}

请指教如何解决这个问题。

最佳答案

(由 OP 在问题编辑中回答。转换为社区 wiki 答案。见 Question with no answers, but issue solved in the comments (or extended in chat))

OP写道:

I solved this by putting rewrite directive in {server} not in {location} section. In my scenario moodle is installed under subfolder: example.com/moodle.


server {
server_name example.com www.example.com;
rewrite ^/moodle/(.*\.php)(/)(.*)$ /moodle/$1?file=/$3 last;

location ^~ /moodle {
try_files $uri $uri/ /index.php?q=$request_uri;
index index.php index.html index.htm;

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9090;
include includes/fastcgi_params.conf;
}
}
}

关于nginx - 带有 Nginx 的 Moodle 2.3 vs 斜杠参数重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18246845/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com