Bug #71399


404 page generates an exception below the page

Added by Arek van Schaijk over 8 years ago. Updated almost 8 years ago.

Must have
Target version:
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:



There seems to be a problem with handling the 404 page in atleast version 7.5 (as far I know) when using SSL.

I've set the [FE][pageNotFound_handling] to "404/" and I'm getting a exception below the generated 404 page.

This seems to cause because the TypoScriptFrontendController->pageErrorHandler() retrieves it's content by using GeneralUtility::getUrl() on line 2110. Since the content is retrieved by GeneralUtility::getUrl() the $_SERVER['HTTP_HOST"] is missing here and this leads to the exception:

Uncaught TYPO3 Exception
#1396795884: The current host header value does not match the configured trusted hosts pattern! Check the pattern defined in $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] and adapt it, if you want to allow the current host header '' for your installation. (More information)

UnexpectedValueException thrown in file
/home/user/domains/ in line 3372.

7 TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv("HTTP_HOST")

03426:     break;
03427:    case 'TYPO3_REQUEST_HOST':
03428:     $retVal = (self::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://') . self::getIndpEnv('HTTP_HOST');
03429:     break;
03430:    case 'TYPO3_REQUEST_URL':

6 TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv("TYPO3_REQUEST_HOST")

03429:     break;
03430:    case 'TYPO3_REQUEST_URL':
03431:     $retVal = self::getIndpEnv('TYPO3_REQUEST_HOST') . self::getIndpEnv('REQUEST_URI');
03432:     break;
03433:    case 'TYPO3_REQUEST_SCRIPT':

5 TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv("TYPO3_REQUEST_URL")

00040:   $method = isset($serverParameters['REQUEST_METHOD']) ? $serverParameters['REQUEST_METHOD'] : 'GET';
00041:   $uri = new Uri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
00043:   $request = new ServerRequest(

4 TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals()

00074:   */
00075:  public function run(callable $execute = NULL) {
00076:   $this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals());
00078:   if ($execute !== NULL) {

3 TYPO3\CMS\Frontend\Http\Application::run()

00031: call_user_func(function() {
00032:  $classLoader = require __DIR__ . '/typo3/../vendor/autoload.php';
00033:  (new \TYPO3\CMS\Frontend\Http\Application($classLoader))->run();
00034: });

2 {closure}()
1 call_user_func(Closure)

00032:  $classLoader = require __DIR__ . '/typo3/../vendor/autoload.php';
00033:  (new \TYPO3\CMS\Frontend\Http\Application($classLoader))->run();
00034: });

A temporary workaround for this is to set [FE][pageNotFound_handling] to "REDIRECT:/404/".

Actions #1

Updated by Ralf Merz over 8 years ago


I´m on my first v7 project. All my vhost are configured the same way meaning I copy the configuration and change the paths.
On my 6.x instances, the 404 handling works.
Now on my first v7 instance, which I have started with 7.3 and was always updating to master until 7.6.0, the 404 pageNotFound_handling does not work correctly.
I have core 7.6.0, gridelements (7-LTS-compatibility branch), realurl (latest 1.x) and my own template extension.

I do not get an exception like Arek does, but after the closing html-tag I have a new 404 error document like:

<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />

This is also rendered below the "normal" page if I uninstall realurl and call an id that does not exist.

Hope someone knows about that.

Edit: What I can confirm is, that with "REDIRECT:/404/" it works.


Actions #2

Updated by Helmut Hummel over 8 years ago

Ralf Merz wrote:

I do not get an exception like Arek does, but after the closing html-tag I have a new 404 error document like:

Do you have curl enabled? I can reproduce this with curl disabled as well.

With curl, everything is fine. However the original report I cannot reproduce (host parttern mismatch)

Actions #3

Updated by Helmut Hummel over 8 years ago

  • Status changed from New to Needs Feedback

Can you provide more info?

  1. Do you have curl enabled?
  2. If not, does it work for you with curl enabled?
  3. How does your hostname look like? any ports specified?
Actions #4

Updated by Ralf Merz over 8 years ago

Hi Helmut,

good point! Thank you for figuring this out. Yes, in deed, my curl was disabled. When I enable it, the 400 Bad Request has gone.
This should answer 1. and 2. :)
And for 3.: My hostname is nothing special. http://project.merzilla.loc/
So due to Nicoles recommendation on slack I tried to set

$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*\.merzilla\.loc';


Well, but now I guess it´s curl. When I enable it, pageNotFound_handling works. The PHP version is 5.6.2

Thank you and regards

Actions #5

Updated by Arek van Schaijk over 8 years ago

Hi Helmut,

CURL is enabled on the server but [SYS][curlUse] is set to zero per default. When turning it on this solves the problem.

Hostname is just xyz.tld.ext and there are no ports specified.


Actions #6

Updated by Claus Harup over 8 years ago

I had the same issues - Setting [SYS][curlUse] = 1 fixes the issue!!

NB: My [SYS][trustedHostsPattern] = SERVER_NAME

Actions #7

Updated by Alexander Opitz about 8 years ago

So, can we close this issue?

Actions #8

Updated by Riccardo De Contardi almost 8 years ago

  • Status changed from Needs Feedback to Closed

No feedback within the last 90 days => closing this ticket.

If you think that this is the wrong decision or think that there is still work to be done, then please open a new ticket and add a relation to this ticket number.

Thank you


Also available in: Atom PDF