[TYPO3-english] Best practice for multidomain and page-not-found-handling

Christopher Torgalson bedlamhotel at gmail.com
Wed Mar 16 00:52:03 CET 2011


Hi,

On Tue, Mar 15, 2011 at 4:24 PM, Patrick Rodacker
<patrick.rodacker at the-reflection.de> wrote:
> Hi list,
>
> I have a question regarding your opinions on the following issue. I have a
> multidomain setup where each domain has its own page tree. Some of the
> domains support multiple languages whereas each page tree has its own
> default language. So it's a mixture of a Multi- and Single-Tree concept.
>
> Regarding the page-not-found-handling the goal was to define a pid via
> TypoScript for each page tree pointing to a page handling the 404 error
> content output. Since the setting
> $TYPO3_CONF_VARS['FE']['pageNotFound_handling'] supports the usage of a user
> function (USER_FUNCTION:...) I have implemented a function which gets the
> page where the sys_domain record for the current domain is located. Then I
> initialize part of the TSFE object with this page and read the template to
> get the pid from TypoScript.  I also use a local instance of tslib_content
> (cObj) for correct typolinks (realurl).
>
> In my opinion this is kind of a "dirty approach" and I wonder if there there
> is a better way to implement configurable 404 error pages, which could be
> easily edited and localized from within the backend.
>
> I appreciate any ideas on this topic or hints to a different approach.

I'm not sure I understand the reasons behind your current (complex!)
method, so I apologise if my suggestion is too limited for what you
need. In any case, I've had no problems using a method like this:

switch ($_SERVER['SERVER_NAME']) {
  case 'www.example.com':
    $page_not_found_id = 123;
    break;
  default:
    $page_not_found_id = 456;
}
$url_pattern = 'index.php?id=%d'
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] =
sprintf($url_pattern, $page_not_found_id);

Obviously, the two main issues here are:

1) if you have an always-changing set of domains, this is far too
primitive since you'd need to add both domains and page ids, and
2) if your editors delete the pages referenced here, your 404s break
(but you can prevent this by setting the ownership of the 404 pages)

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


More information about the TYPO3-english mailing list