[TYPO3-english] page access restrictions redirect
Michael Cannon
mc at aihr.us
Mon Sep 12 15:38:37 CEST 2011
Tom,
Page access redirection was a major pain of mine as well till I figured out the following bits.
1. In TYPO3 page, set the page properties Access to require login or a user group. Do NOT set the Login Mode.
2. In localconf.php...
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'USER_FUNCTION:fileadmin/scripts/pageNotFoundHandling.php:user_pageNotFound->pageNotFound';
3. In fileadmin/scripts/pageNotFoundHandling.php...
<?php
define(LOGIN_URL, "http://www.example/subscribe/login-successful/login.html");
define(NOTFOUND_URL, "http://www.example/");
class user_pageNotFound {
function pageNotFound($param, $ref) {
if ($param["pageAccessFailureReasons"]["fe_group"] != array(""=>0)) {
header("HTTP/1.0 403 Forbidden");
$url = LOGIN_URL."?redirect_url=" . $param["currentUrl"];
} else {
$url = NOTFOUND_URL;
}
session_start();
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
session_write_close();
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_COOKIE, $strCookie);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
}
?>
--
Michael Cannon
President, Aihrus
Italy +39 366 702 7237
US +1 617 539 6072
Professional TYPO3 Support Since 2003
http://aihr.us
More information about the TYPO3-english
mailing list