E107: How 404 page in e107 works?

Created on 8 Jun 2018  路  9Comments  路  Source: e107inc/e107

I thought this:

If I set Redirect to System not found page ON, it will go to file error.php and display content of this page.

But it doesn't work this way. Any 404 displays browser HTTP ERROR 404.

But if I set Associate Root namespace to Page - it will go to page.php and method processViewPage() will display page with this content.

        if(!$sql->gen($query))
        {
            header("HTTP/1.0 404 Not Found");

            // ---------- New (to replace values above) ----

            $this->page['page_title'] = LAN_PAGE_12;            // ***** CHANGED
            $this->page['sub_title'] = '';
            $this->page['page_text'] = LAN_PAGE_3;
            $this->page['comments'] = '';
            $this->page['rating'] = '';
            $this->page['np'] = '';
            $this->page['err'] = TRUE;
            $this->page['cachecontrol'] = false;
              }

define("LAN_PAGE_12", "Invalid page");
define("LAN_PAGE_3", "Requested page does not exist");

I use default e107 htaccess. There is this:

# Custom  pages for php scripts only
<FilesMatch \.php$>
    ErrorDocument 400 /error.php?400
    ErrorDocument 401 /error.php?401
    ErrorDocument 403 /error.php?403
    ErrorDocument 404 /error.php?404
    ErrorDocument 500 /error.php?500
</FilesMatch>

I tried to use absolute path there and nothing.

How this should work?

testing required question

All 9 comments

Funny, next default installation on the same server, it displays e107 error page. If I set Redirect to System not found page ON, I got browser 404 error.

@lonalore any thoughts?

Adding here too:

Could somebody explain me this: google has indexed this url website/?cat.30 - you got message that page listing is turned off, otherwise book/chapter tree is listed. "page" is defined as root namespace.

Why this page doesn't end with 404? This category never existed, last ID is 25...

image

image

@lonalore will be able to explain. There is another issue I found related to this. If a form includes an image tag pointing to a URL (bla.jpg) and that image is not found, it will now return a 404 error page, and reset the form token. When the form is submitted, the user will get an "Unauthorized Access" message.

I believe we need to limit these error page messages to .php files.
@SimSync Thoughts?

With news not existing pages are marked like "soft 404" from google

@Jimmi08 I think i found the issue why the redirect didn't work. Please test, once the PR is merged. Thanks!

I think this should stay open. I didn't get an answer to how 404 works.
I try again to explain what I am asking.

url_error_redirect is FALSE

  1. if there is a wrong URL (standalone page, f.e. some mistypo) f.e. contact2.php - URL is not changed and the error page template is displayed.

  2. in the same case but with url_main_module = page, this code is executed:
    function processViewPage()
    if(!$sql->gen($query))
    { ...
    header("HTTP/1.0 404 Not Found"); ...
    }
    (Invalid page, Requested page does not exist)

  3. with /news/ there is only message
    Error 404 - Document Not Found and other news are displayed.

url_error_redirect is TRUE

  1. result is redirection ?route=system/error/404&type=routeError
  1. no change, no redirection, (Invalid page, Requested page does not exist)

  2. no redirection

What I am trying to do? With plugin and e_module to log all 404 urls. Now I am just trying to understand how this works in e107. Thanks

Was this page helpful?
0 / 5 - 0 ratings