You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Redirect to the website root or language root (e.g. en/)if (\Environment::get('relativeRequest') == '')
{
if (\Config::get('addLanguageToUrl') && !\Config::get('doNotRedirectEmpty'))
{
$arrParams = array('_locale' => $objRootPage->language);
$strUrl = \System::getContainer()->get('router')->generate('contao_index', $arrParams);
$strUrl = substr($strUrl, strlen(\Environment::get('path')) + 1);
static::redirect($strUrl, 301);
}
elseif (($objPage = \PageModel::findFirstPublishedByPid($objRootPage->id)) !== null)
{
// Redirect if the page is not the language fall back or the alias is not "index" or "/" (see #8498 and #8560)if (!$objRootPage->fallback || !in_array($objPage->alias, array('index', '/')))
{
static::redirect($objPage->getFrontendUrl(), 302);
}
}
}
from Frontend.php#L343-L363 causes an infinite redirect under the following setup for example:
Reproduction
Create the following website structure:
Set a page layout for each website root.
The English website root has the language en set and is not the fallback.
The German website root has the language de set and it is the fallback.
The English Home page has the Alias index, the German Home page has the Alias home.
Set contao.prepend_locale to false.
Set the primary language of your browser to en.
Open the website (without a request parameter) in the frontend. Contao will redirect you infinite times.
Cause
Since addLanguageToUrl is false, we will arrive at this bit of code:
elseif (($objPage = \PageModel::findFirstPublishedByPid($objRootPage->id)) !== null)
{
// Redirect if the page is not the language fall back or the alias is not "index" or "/" (see #8498 and #8560)
if (!$objRootPage->fallback || !in_array($objPage->alias, array('index', '/')))
{
static::redirect($objPage->getFrontendUrl(), 302);
}
}
Since the Accept-Language is en the root page found from
will be the english one and the first published page within that website root is the English Home page with the alias index. However, since that website root is not defined as the fallback language, Contao will redirect to the first published page within the website root. And since that page has the alias index, the redirect will be an empty request and the whole thing starts over again.
The text was updated successfully, but these errors were encountered:
Description
-----------
The preview toolbar is not present on any error page.
So in case you have a restricted webpage and the first page is a login form with HTTP code 401, not having the preview toolbar is an issue.
The preview toolbar should explicitly be available on pages with error code
- 401
- 403
- 404
I decided to allow any HTTP codes expect 300-399 (redirects) and 500-599 (server errors).
Commits
-------
61aaf093 Show preview toolbar on error pages
This code
from Frontend.php#L343-L363 causes an infinite redirect under the following setup for example:
Reproduction
en
set and is not the fallback.de
set and it is the fallback.index
, the German Home page has the Aliashome
.contao.prepend_locale
tofalse
.en
.Open the website (without a request parameter) in the frontend. Contao will redirect you infinite times.
Cause
Since
addLanguageToUrl
isfalse
, we will arrive at this bit of code:Since the
Accept-Language
isen
the root page found fromwill be the english one and the first published page within that website root is the English Home page with the alias
index
. However, since that website root is not defined as the fallback language, Contao will redirect to the first published page within the website root. And since that page has the aliasindex
, the redirect will be an empty request and the whole thing starts over again.The text was updated successfully, but these errors were encountered: