Posted By

FazzyX on 12/08/10


Tagged

typo3 404 403 401 pageNotFoundHandling


Versions (?)

pageNotFoundHandling


 / Published in: PHP
 

TYPO3 pageNotFoundHandling with determination of 404 and 401/403 stats.

Modify LOGIN_URL and NOTFOUND_URL !

Save as pageNotFoundHandling.php and point to this from Install Tool setting.

[FE][pageNotFound_handling] = USER_FUNCTION:fileadmin/scripts/pageNotFoundHandling.php:user_pageNotFound->pageNotFound

Enable cURL by setting [SYS][curlUse] = 1 at Install Tool

cURL must provide from system !

To get redirected after login to the request page, you have to use 'defined by GET/POST-Vars' at felogin redirect mode

  1. <?php
  2. define(LOGIN_URL, "http://domain.tld/login.html");
  3. define(NOTFOUND_URL, "http://domain.tld/not-found.html");
  4.  
  5. class user_pageNotFound {
  6. function pageNotFound($param, $ref) {
  7. if ($param["pageAccessFailureReasons"]["fe_group"] != array(""=>0)) {
  8. header("HTTP/1.0 403 Forbidden");
  9. $url = LOGIN_URL."?redirect_url=" . $param["currentUrl"];
  10. } else {
  11. $url = NOTFOUND_URL;
  12. }
  13.  
  14. $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
  15.  
  16. $c = curl_init();
  17. curl_setopt($c, CURLOPT_URL, $url);
  18. curl_setopt($c, CURLOPT_COOKIE, $strCookie);
  19. $contents = curl_exec($c);
  20. curl_close($c);
  21.  
  22. if ($contents) return $contents;
  23. else return FALSE;
  24. }
  25. }
  26. ?>

Report this snippet  

You need to login to post a comment.