How to modify URLs ?

How to modify URLs ?

by Developer Cabrilog -
Number of replies: 4

Hello everyone.

Il my "moodle" directory, I created the directory "test" in which I created the directory "web". Thus, to access "web" via localhost, I must type: http://localhost/moodle/test/web.

So now I would like to access files in "web" directory via http://localhost/moodle/test.

How is it possible to do that without adding any PHP file, just by handling URLs?

Thank you.

Average of ratings: -
In reply to Developer Cabrilog

Re: How to modify URLs ?

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can achieve this with Apache's mod_rewrite (or equivalent, most web servers support something similar).

You'll want a rule looking something like

RewriteRule ^/moodle/test(.*) /moodle/test/web$1

In reply to Mark Johnson

Re: How to modify URLs ?

by Developer Cabrilog -

Thanks for your answer, but I'd prefer not to use Apache URL rewriting module.

I think it might be possible to configure this using Moodle application's functions, but I can't find what function I could call and how.

Thanks.

In reply to Developer Cabrilog

Re: How to modify URLs ?

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Gaetan,

The reason I suggested URL rewriting is because you said you didn't want to use PHP files, just URL handling.  If you're happy to use PHP, you can use Moodle's redirect() function (or event PHP's own header() function in a pinch).

In reply to Mark Johnson

Re: How to modify URLs ?

by Developer Cabrilog -

Oh, excuse me Mark. I wasn't sufficiently clear. smile

I meant that I want to use the PHP functions included in the Moodle application, so I don't want to create any new file (PHP or other types).

Thanks for your answer though!