moodle-local_cleanurls icon indicating copy to clipboard operation
moodle-local_cleanurls copied to clipboard

Rewrite router is NOT working (inbound links)

Open cwohlers84 opened this issue 8 years ago • 21 comments

Hey,

I installed this great plugin and I got the message, that everythink is fine with routing, after I made the changes to the apache. So I activated the Cleaning.

Now i get two messages:

Rewrite router is NOT working (inbound links) Rewrite function is configured properly (outbound links)

What's the problem here?

Greets, Chris

cwohlers84 avatar Nov 03 '16 16:11 cwohlers84

Do you restart apache? And is mod_rewrite enabled? At the bottom of this section in the readme is how to debug the mod_rewrite settings:

https://github.com/brendanheywood/moodle-local_cleanurls#step-3-add-the-apache-rewrite-to-the-custom-router

brendanheywood avatar Nov 04 '16 00:11 brendanheywood

Hey,

yea mod rewrite is active and i also tried the way over htaccess. Here is the same.

The Link-rewrite is working properly, i just get the two messages.

What else can i do?

Greets,

Chris

cwohlers84 avatar Nov 04 '16 09:11 cwohlers84

I also took a look into the error log.

There is nothin written with your plugin. So no errors here.

Greets,

Chris

cwohlers84 avatar Nov 04 '16 10:11 cwohlers84

I've just updated the readme with a bunch of trouble shooting steps, can you please work through these and tell me where you get stuck, and what version of moodle and apache you are on:

https://github.com/brendanheywood/moodle-local_cleanurls#trouble-shooting

brendanheywood avatar Nov 06 '16 23:11 brendanheywood

Yes, I'm also getting this. I get the Rewrite router is NOT working (inbound links) warning in settings and several tests show as Failed. However, everything seems to work. URLs are cleaned mostly and I get a themed moodle error page when trying an invalid URL instead the default 404 apache error.

I tried the troubleshooting in the readme but I couldn't notice anything wrong in the error log. E.g.: log shows that an invalid URL returned a 404, but the Webserver Test page shows that test as Failed. In fact, only the first 3 tests shows as Passed.

ajwsert avatar Dec 15 '17 18:12 ajwsert

if the pages actually work, but the tests fail, then moodle may have an issue curl'ing to itself.

brendanheywood avatar Dec 17 '17 22:12 brendanheywood

Still have problems with this great solution. Had it working for the theme Academi but changed to Adaptable today and clean urls stopped working and got only "invalid url". Even stranger: after disabling the cleaning - all tests pass with Adaptable theme. But when activating I get the "invalid url" for all pages. (cleaned all caches - the cron.php is still functioning).

WebmasterCollege avatar Jan 25 '18 22:01 WebmasterCollege

Hi, I'm also getting this error. Do you have the solution to this problem by now?

GrayFullbuster1997 avatar Apr 16 '19 06:04 GrayFullbuster1997

hi @GrayFullbuster1997 note this plugin is experimental and we are not activity working it

brendanheywood avatar Apr 16 '19 06:04 brendanheywood

@brendanheywood do you plan to update the plugin?

I have same error:

` etching: https://edu.....com/local/cleanurls/tests/webserver/configphp.php *** DATA DUMP: Header *** HTTP/1.1 200 OK Date: Mon, 16 Mar 2020 07:39:33 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.3.15 X-Powered-By: PHP/7.3.15 Set-Cookie: MoodleSession=s2i9ade60snuq1jvg19mngoa0s; path=/; secure; HttpOnly Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache Access-Control-Allow-Origin: * Content-Length: 47 Content-Type: text/html; charset=utf-8 *** DATA DUMP: Body *** $CFG lost
$CFG->urlrewriteclass OK
*** DATA DUMP: End ***

*** PASSED: assert_same *** Expected: 200 Actual: 200

*** FAILED: assert_contains *** Needle: '$CFG OK' Haystack: '$CFG lost
$CFG->urlrewriteclass OK
'

*** PASSED: assert_contains *** Needle: '$CFG->urlrewriteclass OK' Haystack: '$CFG lost
$CFG->urlrewriteclass OK
' `

nahimdam avatar Mar 16 '20 07:03 nahimdam

Ok, I found that the first line of config.php has:

unset($CFG);

Comment and Pass test!

#unset($CFG);

nahimdam avatar Mar 16 '20 07:03 nahimdam

@nahimdam sorry I am not maintaining this plugin, nor have we ever used it in production

brendanheywood avatar Mar 16 '20 13:03 brendanheywood

How sad, your component is very valuable for search engine positioning on educational content with moodle.

nahimdam avatar Mar 18 '20 18:03 nahimdam

I agree, I just haven't found a client yet who agreed enough to help work through the remaining issues. Most of this plugin is one series of hacks after another, it's all made very difficult by the lack of a front controller concept in moodle.

brendanheywood avatar Mar 18 '20 22:03 brendanheywood

Hi! Facing the same problem. Just wondering if anyone finds their way out? Thank you so much!

Pseudoman21 avatar May 24 '22 09:05 Pseudoman21

First, I'll repeat that this plugin isn't supported and hasn't been touched in half a decade.

That said I just fired it up and it mostly worked but I got similar errors. I think if we get this working again I'd rewrite it so that instead of going to a custom router then it is part of the 404 error page handling already in moodle.

If someone can find some funding for this please contact us:

https://catalyst-au.net/contact-locations/sydney#email-us?location=Sydney

Also pull requests welcome

brendanheywood avatar May 24 '22 23:05 brendanheywood

Hi Brenda!

I'm having problems with the plugin and the hosting tells me that uncleaner.php and router.php are causing problems.

I show you...

Local extensions

/admin/category.php?category=localplugins give me this message:

Rewrite function is configured properly (outbound links) ✔

Clean URLs

/admin/settings.php?section=local_cleanurls it gives me these two messages:

Rewrite router is NOT working (inbound links)✔ Rewrite function is configured properly (outbound links)

Clean URLs Webserver Test

/local/cleanurls/webservertest.php

Fetch an existing directory without slash ERROR details

/local/cleanurls/webservertest.php?details=webtest_directory_without_slash

En el servertest es "Fetch an existing directory without slash" that is giving us the error.

In the error link it tells us this ERROR, but I wouldn't know exactly what we should do. Can you shed some light on this error for me?

The rest is all ok

*** FAILED: assert_contains ***

Needle: ' Location:' Haystack: 'HTTP/2 301 date: Fri, 16 Dec 2022 10:58:03 GMT content-type: text/html; charset=iso-8859-1 location: http://campus.mendibilformacion.com/local/cleanurls/tests/webserver/ age: 0 cf-cache-status: DYNAMIC report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=%2Fe4hdQ9wQ3QYmPyX5gvIbKHYL5D5Ejg2eplaal5MOCkvZVmWxr%2FAkkDR6EoaJM3UuruR%2FjYQ3AOwR8Z0aOtNdyiLlITiAWrGFJ6fJyLYtFOvJI9RwUylFVVorIllkHI82xyk5uuWp2w8%2FHvlzRXx"}],"group":"cf-nel","max_age":604800} nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800} server: cloudflare cf-ray: 77a6e6d29987667d-MAD alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400'

I hope we can resolve this issue. Sincerely

iUranga

HAZLANMKT avatar Dec 19 '22 11:12 HAZLANMKT

Hi Brenda!

I attach the code

uncleaner.phn

In the hosting, it is indicating this in the file uncleaner.php (Lines 43, 50 and 81):

43 and 50 lines:

public static function unclean($clean) {
    $unclean = self::load_cache($clean);
    if (!is_null($unclean)) {
        return $unclean;
    }

    $unclean = self::perform_uncleaning($clean);

    self::save_cache($clean, $unclean);
    return $unclean;
}

81 line:

   if (!empty($lastnode->get_subpath())) {
        $subpath = implode('/', $lastnode->get_subpath());
        debugging("Could not unclean until the end of address: {$subpath}", DEBUG_DEVELOPER);
    }

weblib.php

    if (NO_DEBUG_DISPLAY) {
        // Script does not want any errors or debugging in output,
        // we send the info to error log instead.
        error_log('Debugging: ' . $message . ' in '. PHP_EOL . $from);

    } else if ($forcedebug or $CFG->debugdisplay) {
        if (!defined('DEBUGGING_PRINTED')) {
            define('DEBUGGING_PRINTED', 1); // Indicates we have printed something.
        }
        if (CLI_SCRIPT) {
            echo "++ $message ++\n$from";
        } else {
            echo '<div class="notifytiny debuggingmessage" data-rel="debugging">' , $message , $from , '</div>';
        }

    } else {
        trigger_error($message . $from, E_USER_NOTICE);
    }
}
return true;

}

HAZLANMKT avatar Dec 19 '22 13:12 HAZLANMKT

Fetch Clean URLs self test Failed Clean URLs has a self test URL logical URL that should return "OK" when requested. This URL does not map to a file which ensures it was routed through Clean URLs. This self test URL should work even if the plugin is not enabled.
Test rewrite without parameters Failed Clean URLs should work for any URL when no parameters in the query string are supplied.
Test rewrite with a simple parameter Failed Clean URLs should work when extra parameters in query string are supplied.
Test rewrite with an encoded parameter Failed Clean URLs should work when encoded parameters in query string are supplied.

lonewolf334 avatar Apr 04 '24 07:04 lonewolf334

i got these 4 errors can anyone help me with this i got stuck

lonewolf334 avatar Apr 04 '24 07:04 lonewolf334

how can i remove those errors?? @HAZLANMKT

lonewolf334 avatar Apr 04 '24 07:04 lonewolf334