[TYPO3-english] PHP warning parse_url(http:///404/)

Christopher Torgalson bedlamhotel at gmail.com
Mon Dec 6 18:30:13 CET 2010


Hi there,

On Mon, Dec 6, 2010 at 6:10 AM, Tomas Havner <tomas.havner at kansli.lth.se> wrote:
>  Christopher Torgalson skrev 2010-12-03 16:50:
>>
>> Hi,
>>
>> On Fri, Dec 3, 2010 at 12:38 AM, Christian Futterlieb
>> <christian at futterlieb.ch>  wrote:
>>>
>>> Hi Thomas
>>>
>>> Take a look at extension pagenotfoundhandling ([1] and [2]).
>>>
>>> Regards, Christian
>>>
>>> [1] http://forge.typo3.org/projects/extension-pagenotfoundehandling
>>> [2]
>>> http://typo3.org/extensions/repository/view/pagenotfoundhandling/current/
>>>
>>> On 12/03/2010 09:13 AM, Tomas Havner wrote:
>>>>
>>>> I host many sites, so I have set the page not found handling to 404. Is
>>>> there a solution to define one 404-page per site without using /404?
>>
>> If you need to do it for multiple domains, that extension may be what
>> you need (though if you have a consistent and reasonably low number of
>> domains, you can also do it with a switch statement in
>> localconf.php–see below for a short example).
>>
>> But in any case, as I understand it, Realurl is not available at the
>> stage of the request where 404 pages are handled (i don't know about
>> Cooluri, I assume it's similar). That means (at least in
>> localconf.php) you need to set the 404 url to e.g. /index.php?id=123.
>> It's possible that something has changed which will make it possible
>> to use /404, but as I mentioned previously, it doesn't make a lot of
>> sense to have a special alias for a 404 page which is _never_ accessed
>> by its own URL (i.e. the unattractive /index.php?id=245 URL is never
>> shown...)
>>
>>
>> switch($_SERVER['SERVER_NAME']) {
>>   case 'www.example.com':
>>     $page_not_found_id = '216';
>>     break;
>>   default:
>>     $page_not_found_id = '54';
>> }
>> $TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = '/index.php?id='.
>> $page_not_found_id;
>>
>>
> Thank you all for your input. My "solution" was at the end:
> $TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'http://' .
> $_SERVER['SERVER_NAME'] . '/404/'; I dont know if its the perfect solution,
> but it stopped the php-warnings in my log-file.

Unless I'm mistaken, you should adopt something closer to my code
instead because it may not be safe for you to trust the contents of
$_SERVER['SERVER_NAME']. If you use the switch() construct, you're
effectively whitelisting the permissible domains. It should be easy
enough unless you have dozens of domain names or more or unless the
domain names are constantly changing...

-- 
Christopher Torgalson
http://www.typo3apprentice.com/


More information about the TYPO3-english mailing list