Nginx, Moodle 4.4 Slash Arguments and only text issue

Nginx, Moodle 4.4 Slash Arguments and only text issue

by Emre Gover -
Number of replies: 1

After "slash arguments" enabled, if the graphics do not show , but only texts are shown, then update nginx.conf file.

delete default "location php block" and replace it with:

#Rewrite rule for Moodle URLs (modify if necessary)

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

location ~ ^(.+\.php)(.*)$ {

# Document root for Moodle files

root /usr/share/nginx/html/moodle/;

# use your own moodle path

# Split URL path for PHP-FPM processing

fastcgi_split_path_info ^(.+\.php)(.*)$;

# Default script for directories

fastcgi_index index.php;

# Upstream PHP-FPM server

fastcgi_pass 127.0.0.1:9000;

# Include MIME type definitions

include /etc/nginx/mime.types;

# Include pre-defined parameters for PHP-FPM

include fastcgi_params;

# Set PATH_INFO variable for PHP-FPM

fastcgi_param PATH_INFO $fastcgi_path_info;

# Set SCRIPT_FILENAME variable for PHP-FPM

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

}


Explanation:
  • The rewrite rule placed outside the location block intercepts incoming URLs before they reach the location block.
  • If the URL matches the pattern, it gets rewritten to include "?file=/" before the additional path information.
  • The location block then takes over for the rewritten URL and handles the request as a standard PHP request for Moodle.

qqq.com/pluginfile.php/1/theme_boost_magnific/Banner.jpg    becomes

qqq.com/pluginfile.php?file=/1/theme_boost_magnific/Banner.jpg

Average of ratings: -