Issue Story Closed

#65730Usability pageNotFound handling

Job Rutgers 03/14/15, 12:20 updated 04/13/18, 11:36

Description

In my opinion the setup for the pageNotFound handling in the current Typo3 versions is not that user friendly. I know there are some extensions to make it better, but I think Typo3, as a modern CMS, should make the setup more user friendly out of the box.
For example a configuration in the backend for each root level/domain.

My current configuration feels a bit strange to me:
[FE][pageNotFound_handling] = USER_FUNCTION:fileadmin/php/pageNotFound.php:user_pageNotFound->pageNotFound
with pageNotFound.php:

define(LOGIN_URL, 'https://www.domain.nl/login');
define(NOTFOUND_URL, 'https://www.domain.nl/page-not-found');
class user_pageNotFound {
  /*
   * $params = Array mit den Werten currentUrl, reasonText und pageAccessFailureReasons
   * $ref = Referenz auf das Seiten-Objekct von TYPO3 (TSFE)
   */

  function pageNotFound($params, $ref) {

    if(current($params["pageAccessFailureReasons"]["fe_group"]) !== 0) {

      // Benutzer hat eine Seite aus dem geschtzten Bereich aufgerufen, 
      // ist aber nicht eingeloggt -> Login + Redirect

      $login[0] = LOGIN_URL;
      $login[1] = LOGIN_URL;
      $login[2] = LOGIN_URL;
      $L = (array_key_exists('L', $_GET) ? $_GET['L'] : 0);
      header('Location: ' . $login[$L] . '?redirect_url=' . urlencode($params["currentUrl"]));

    } else {

      // Benutzer hat eine nicht existierende Seite aufgerufen -> Error 404

      header("HTTP/1.0 404 Not Found");
      echo implode ('', file (NOTFOUND_URL));
    }
  }
}

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.