Problems with relative paths in resources

Problems with relative paths in resources

by Martin Post -
Number of replies: 2
I have a plain HTML file on our server in the "moodledata" folder referencing a few other files (images, stylesheets etc.) in the same folder (eg <img src="img.gif">), which works as expected when accessing this file directly.

When this file is added as a ressource to Moodle (so that it opens with the Moodle navigation as a top frame), though, all references (links, CSS, images) break. So a link to another file in the same folder doesn’t go to

http://www.SOMESERVER.com/moodledata/2/data/file2.htm

anymore, it now refers to:

http://www.SOMESERVER.com/moodle/file.php?file=/2/data/file2.htm

which doesn’t work.

I basically understand why/how this happens, but can it be avoided? Do I really have to use an absolute path here?
Average of ratings: -
In reply to Martin Post

Re: Problems with relative paths in resources

by Zbigniew Fiedorowicz -
For relative paths to work, you will need to configure your web server so that Moodle works with slasharguments.  That is for relative paths to work, you need to have your web server accept the path syntax
http://www.SOMESERVER.com/moodle/file.php/2/data/file2.htm
instead of
http://www.SOMESERVER.com/moodle/file.php?file=/2/data/file2.htm
In reply to Zbigniew Fiedorowicz

Re: Problems with relative paths in resources

by Martin Post -
Got it. Now, we are using a webhoster, and - as I’m far from being a PHP guru - can you tell me which PHP configuration parameter has to be changed, so I can tell their support people what I want? Thank you!