e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
322 stars 214 forks source link

How 404 page in e107 works? #3179

Open Jimmi08 opened 6 years ago

Jimmi08 commented 6 years ago

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?

Jimmi08 commented 6 years ago

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.

Moc commented 6 years ago

@lonalore any thoughts?

Moc commented 6 years ago

https://github.com/e107inc/e107/pull/2148 https://github.com/e107inc/e107/pull/2153

Jimmi08 commented 6 years ago

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

CaMer0n commented 6 years ago

@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?

Jimmi08 commented 6 years ago

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

SimSync commented 6 years ago

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

Jimmi08 commented 5 years ago

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

  2. no change, no redirection, (Invalid page, Requested page does not exist)

  3. 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

Jimmi08 commented 4 years ago

https://github.com/e107inc/e107/issues/4137