Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-80823

When wwwroot changes serve redirects including the path and query

XMLWordPrintable

    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • MDL-80823-wwwroot-redirect-MOODLE_403_STABLE
    • MDL-80823-wwwroot-redirect
    • Hide

      1) Setup an environment that is served over multiple domain names at the same time, eg oldurl.localhost and newurl.localhost

      2) Set $CFG->debug = (E_ALL | E_STRICT); to show the full x-redirect headers

      3) Configure Moodle to use the 'new' url eg $CFG->wwwroot = 'https://newurl.localhost';

      4) Curl a deep link inside moodle which has both path info and query params using the oldurl eg

      curl -I --insecure https://oldurl.localhost/my/courses.php/path_info?query=param
      HTTP/1.1 303 See Other
      Server: nginx/1.18.0 (Ubuntu)
      Date: Mon, 05 Feb 2024 05:15:57 GMT
      Content-Type: text/html; charset=UTF-8
      Connection: keep-alive
      X-Powered-By: PHP/8.1.2-1ubuntu2.14
      X-Redirect-By: Moodle /lib/setuplib.php:964
      Location: https://newurl.localhost/my/courses.php/path_info?query=param
      Content-Language: en

      5) Confirm that you see the X-Redirect-By which means the redirect was served by Moodle and not by nginx / apache

      6) Confirm that you see the same path and query string as the original request in the Location header eg:

      Location: https://newurl.localhost/my/courses.php/path_info?query=param

       

      Show
      1) Setup an environment that is served over multiple domain names at the same time, eg oldurl.localhost and newurl.localhost 2) Set $CFG->debug = (E_ALL | E_STRICT); to show the full x-redirect headers 3) Configure Moodle to use the 'new' url eg $CFG->wwwroot = 'https://newurl.localhost'; 4) Curl a deep link inside moodle which has both path info and query params using the oldurl eg curl -I --insecure https://oldurl.localhost/my/courses.php/path_info?query=param HTTP/1.1 303 See Other Server: nginx/1.18.0 (Ubuntu) Date: Mon, 05 Feb 2024 05:15:57 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive X-Powered-By: PHP/8.1.2-1ubuntu2.14 X-Redirect-By: Moodle /lib/setuplib.php:964 Location: https://newurl.localhost/my/courses.php/path_info?query=param Content-Language: en 5) Confirm that you see the X-Redirect-By which means the redirect was served by Moodle and not by nginx / apache 6) Confirm that you see the same path and query string as the original request in the Location header eg: Location: https://newurl.localhost/my/courses.php/path_info?query=param  

      If you have a site on lms.moodle.edu and it gets renamed to learn.moodle.edu then you want all the bookmarked links to keep working seamlessly. This can be done at the load balancer but in various setups it is Moodle doing the redirect and it doesn't honor the path and do a full proper redirect. This has lots of SEO benefits so you don't lose page rank when shifting domains.

            brendanheywood Brendan Heywood
            brendanheywood Brendan Heywood
            Owen Herbert Owen Herbert
            Huong Nguyen Huong Nguyen
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 28 minutes
                1h 28m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.