加入收藏 | 设为首页 | 会员中心 | 我要投稿 商洛站长网 (https://www.0914zz.com/)- AI应用、CDN、边缘计算、云计算、物联网!
当前位置: 首页 > 运营中心 > Nginx > 正文

Moodle 2.3与Nginx vs斜杠参数重写

发布时间:2021-01-24 10:57:09 所属栏目:Nginx 来源:互联网
导读:我正在尝试使用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/

我正在尝试使用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中禁用“Slash参数”.哪个是伟大的但是对于尽管前一个选项强制“斜杠参数”的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;
        }
        }
        }

(编辑:商洛站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读