Git Product home page Git Product logo

Comments (6)

brendanheywood avatar brendanheywood commented on June 13, 2024 1

I'm gonna reopen this and treat this as a documentation task to update the readme with an example of this

from moodle-tool_redirects.

dmitriim avatar dmitriim commented on June 13, 2024

hey @VOOM108
It should just work if https://campus.mymoodlesite.com/importantquiz is your moodle page that loads configs and has after_config callback fired, otherwise it's out of scope for that plugin sorry.

from moodle-tool_redirects.

brendanheywood avatar brendanheywood commented on June 13, 2024

If that page doesn't exist at all, but you have setup Moodle to be the handler for your error pages then this should all work.

The setup for this can be found here:

https://docs.moodle.org/dev/Error_pages

ie browser visits

/importantquiz

this doesn't exist and so nginx or apache routes this to the error page at:

/error/index.php

From this page the after_config hook fires and does the detection and then redirects to wherever you want it to based on config

from moodle-tool_redirects.

VOOM108 avatar VOOM108 commented on June 13, 2024

If that page doesn't exist at all, but you have setup Moodle to be the handler for your error pages then this should all work.

The setup for this can be found here:

https://docs.moodle.org/dev/Error_pages

ie browser visits

/importantquiz

this doesn't exist and so nginx or apache routes this to the error page at:

/error/index.php

From this page the after_config hook fires and does the detection and then redirects to wherever you want it to based on config

I added
ErrorDocument 404 /error/index.php
to the .htaccess and it did produce the Moodle error page instead of a simple server 404. However - the result with the redirect was not as expected...

#/importantquiz/#=>/mod/quiz/view.php?id=18

image
Translation: "404: file not found. An unexpected error has occured, because a non-existant page was called."

(In case that makes a difference: It is Moodle 4.1)

from moodle-tool_redirects.

brendanheywood avatar brendanheywood commented on June 13, 2024

Ok this was actually a surprisingly deep rabbit hole but this is now all implemented in #15

If I have test config like this:

#\/vanity#=>/my/

then I get a redirect:

brendan@catau-bri-laptop0372 05:30:17 ~ $ curl -kI https://master.localhost/vanity
HTTP/1.1 303 See Other
...
X-Redirect-By: Moodle /admin/tool/redirects/classes/helper.php:119
Location: https://master.localhost/my/

from moodle-tool_redirects.

brendanheywood avatar brendanheywood commented on June 13, 2024

One caveat is that if you are using nginx then the error pages must be setup like this:

error_page 403 = /error/index.php

and not just like below (the moodle wiki was not like this and is now corrected)

error_page 403 /error/index.php

https://docs.moodle.org/dev/Error_pages

from moodle-tool_redirects.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.