typo3-realurl
typo3-realurl copied to clipboard
Override core 404 handling to prevent subsequent pageNotFoundAndExit()
The default core handling of inaccessible pages (due to access restrictions) is fallback content. For this to work this must be empty:
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = ''
When I need to show a pretty 404 page if a page doesn't exist, then the same config must not be be empty.
This is a problem if I want both handlings (fallback on access denied, 404 on page doesn't exist).
This is fixed in #509
I do not understand this. Please, explain better.
Let's say I have a public page "/products" and a subpage "/products/for-members" that is only accessible to one usergroup. The default behavior is this: A user with that usergroup can visit "/products" and "/products/for-members". A user without that usergroup can visit "/products" and he can also visit "/products/for-members" but he will see the content of "/products". This is a silent fallback, not a redirect- the URL in the address bar will NOT reflect the fallback content. It will still display "/product/for-members".
This is exactly the behavior I want. But I also want proper 404 handling. So when a user visits the page "/products/foo" or "/bar" I want to display a nice 404 page. Now setting $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']
properly will handle this, but then I will loose the silent fallback logic. So this is no good.
realurl to the rescue! \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::checkAlternativeIdMethods
calls the realurl hook that eventually calls \DmitryDulepov\Realurl\Decoder\UrlDecoder::handleNonExistingPostVarSet
. So at this point the system would know if the page actually exists or not. But the only way out from here is \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::pageNotFoundAndExit
which does not support the rendering of a nice 404 page.
So in short, this is what I want and what the PR would support:
- Silent fallback logic on restricted pages
- nice 404 pages on non-existing pages
@dmitryd : did this make any sense to you? I think this would be a really useful feature.
But the only way out from here is \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::pageNotFoundAndExit which does not support the rendering of a nice 404 page.
You can provide your own 404 page using TYPO3 config at this point using $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']
.
But that is precisely the point: if $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']
is used, then we lose the content fallback logic on restricted pages as detailed here: https://github.com/dmitryd/typo3-realurl/issues/510#issuecomment-321066304.