Moodle 2.3与Nginx vs斜线参数重写

时间:2013-08-15 05:30:49

标签: nginx moodle

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

显然,任何人都知道,Moodle正在使用path_info规则发布这样的网址: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;

不适用于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;
}

请告知如何解决此问题。

1 个答案:

答案 0 :(得分:2)

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

OP写道:

  

我通过将重写指令放在{server}而不是{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;
        }
        }
        }