Moodle 2.3与Nginx vs斜线参数重写

Joh*_*era 11 moodle nginx

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

显然任何人都知道,Moodle正在使用path_info规则发布这样的URL:http://example.com/moodle/pluginfile.php/26/mod_scorm/content/1/index.html.为了逃避所有这些噩梦,Moodle提出禁用UI中的"Slash arguments".哪个好.但不是SCORM播放器,尽管有前一个选项,它正在强制"Slash论证".因此,对于禁用的"Slash参数",一切正常并正常.但我唯一的目标是使用SCORM播放器.

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

rewrite ^(.*\.php)(/)(.*)$ $1?file=/$3 last;
Run Code Online (Sandbox Code Playgroud)

哪个不适用于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;
}
Run Code Online (Sandbox Code Playgroud)

请告知如何解决这个问题.

Bri*_*汤莱恩 2

(OP 在问题编辑中回答。转换为社区 wiki 答案。请参阅没有答案的问题,但问题在评论中解决(或在聊天中扩展)

OP 写道:

我通过将重写指令放在{server}not in{location}部分中解决了这个问题。在我的场景中,moodle 安装在子文件夹下: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;
        }
        }
        }
Run Code Online (Sandbox Code Playgroud)