This is now solved using the link above.
It is worth noting that copying and pasting the code from the above link doesn't work straight away as, for me at least, some of the comments and code lines merged. The only changes are to the function get_file_arguements from line 1120 approx.
This is the code I used, from
https://diocesanos-es.translate.goog/blogs/equipotic/2021/01/02/actualizado-moodle-a-v3-10-en-servidor-de-1and1-ionos/?_x_tr_sl=es&_x_tr_tl=en&_x_tr_hl=en-GB&_x_tr_pto=wapp
I hope it helps.
////////////////////////////////////////////////////////////////////////////////
/**
* Extracts file argument either from file parameter or PATH_INFO
*
* Note: $scriptname parameter is not needed anymore
*
* @return string file path (only safe characters)
*
* Edited by DEmsley due to slash arguements not being available from Ionos.
* 19/01/22
*
*/
function get_file_argument() {
global $SCRIPT;
$relativepath = false;
$hasforcedslashargs = false;
$pathinfo = ''; if (isset($_SERVER['PATH_INFO'])) { $pathinfo = $_SERVER['PATH_INFO']; }
else if (isset($_SERVER['ORIG_PATH_INFO'])) { $pathinfo = $_SERVER['ORIG_PATH_INFO'];
}
if (isset($_SERVER['REQUEST_URI']) && !empty($_SERVER['REQUEST_URI'])) {
// Checks whether $_SERVER['REQUEST_URI'] contains '/pluginfile.php/'
// instead of '/pluginfile.php?', when serving a file from e.g. mod_imscp or mod_scorm.
if ((strpos($_SERVER['REQUEST_URI'], '/pluginfile.php/') !== false)
&& !empty($pathinfo)) {
// Exclude edge cases like '/pluginfile.php/?file='.
$args = explode('/', ltrim($pathinfo, '/'));
$hasforcedslashargs = (count($args) > 2); // Always at least: context, component and filearea.
}
}
if (!$hasforcedslashargs) {
$relativepath = optional_param('file', false, PARAM_PATH);
}
if ($relativepath !== false and $relativepath !== '') {
return $relativepath;
}
$relativepath = false;
// Then try extract file from the slasharguments.
if (stripos($_SERVER['SERVER_SOFTWARE'], 'iis') !== false) {
// NOTE: IIS tends to convert all file paths to single byte DOS encoding,
// we can not use other methods because they break unicode chars,
// the only ways are to use URL rewriting
// OR
// to properly set the 'FastCGIUtf8ServerVariables' registry key.
if ($pathinfo !== '') {
// Check that PATH_INFO works == must not contain the script name.
if (strpos($pathinfo, $SCRIPT) === false) {
$relativepath = clean_param(urldecode($pathinfo), PARAM_PATH);
}
}
} else {
// All other apache-like servers depend on PATH_INFO.
if ($pathinfo !== '') {
if (isset($_SERVER['SCRIPT_NAME']) and strpos($pathinfo, $_SERVER['SCRIPT_NAME']) === 0) {
$relativepath = substr($pathinfo, strlen($_SERVER['SCRIPT_NAME']));
}
else {
$relativepath = $pathinfo;
}
$relativepath = clean_param($relativepath, PARAM_PATH);
}
}
return $relativepath;
}
//////////////////////////////////////////////////////////////////////////