Project

General

Profile

Actions

Bug #71399

closed

404 page generates an exception below the page

Added by Arek van Schaijk about 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-11-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Hi,

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/example.com/private_html/typo3/sysext/core/Classes/Utility/GeneralUtility.php in line 3372.

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

/home/user/domains/example.com/private_html/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
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")

/home/user/domains/example.com/private_html/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
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")

/home/user/domains/example.com/private_html/typo3/sysext/core/Classes/Http/ServerRequestFactory.php:
00039: 
00040:   $method = isset($serverParameters['REQUEST_METHOD']) ? $serverParameters['REQUEST_METHOD'] : 'GET';
00041:   $uri = new Uri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
00042: 
00043:   $request = new ServerRequest(

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

/home/user/domains/example.com/private_html/typo3/sysext/frontend/Classes/Http/Application.php:
00074:   */
00075:  public function run(callable $execute = NULL) {
00076:   $this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals());
00077: 
00078:   if ($execute !== NULL) {

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

/home/user/domains/example.com/private_html/index.php:
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)

/home/user/domains/example.com/private_html/index.php:
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 about 9 years ago

Hi,

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:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>

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.

Yours
merzilla

Actions #2

Updated by Helmut Hummel about 9 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 about 9 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 about 9 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';

form "SERVER_NAME".

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
Ralf

Actions #5

Updated by Arek van Schaijk almost 9 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.

Cheers,
Arek

Actions #6

Updated by Claus Harup almost 9 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 over 8 years ago

So, can we close this issue?

Actions #8

Updated by Riccardo De Contardi over 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

Actions

Also available in: Atom PDF