[TYPO3-english] realURL with multisite

Bernhard Kraft kraftb at kraftb.at
Sun Feb 1 11:54:50 CET 2009


Hallo Luca !

luca schrieb:

> site2 (id=4)   [www.domainname2.com]
>  |_page1 (id=5)
>  |_page2 (id=6)
>  |_...
> 
> ------
> config.simulateStaticDocuments = 0
> config.baseURL = http://www.domainname1.com
> config.tx_realurl_enable = 1
> config.uniqueLinkVars = 1
> config.linkVars = L
> config.defaultToHTMLsuffixOnPrev = 1
> -------

On Site2 (id=4) you should of course set:

config.baseURL = http://www.domainname2.com

To let things work properly ...

> $TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
>     'www.domainname1.com' => $tx_realurl_config,
>     'domainname1.com' => 'www.domainname1.com',
>     'www.domainname2.tld' => $tx_realurl_config,
>     'domainname1.com' => 'www.domainname1.com',
> );

Here $tx_realurl_config is NOT set ... (or did you set
it anywhere before ???)

So this should be rather:

----------------------------
$tx_realurl_config = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname1.com']=$tx_realurl_config;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domainname1.com']=$tx_realurl_config;

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname2.tld']=$tx_realurl_config;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domainname2.tld']=$tx_realurl_config;

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname1.com']['pagePath']['rootpage_id']=1;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domainname1.com']['pagePath']['rootpage_id']=1;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname2.tld']['pagePath']['rootpage_id']=4;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domainname2.tld']['pagePath']['rootpage_id']=4;

unset($tx_realurl_config);
-----------------------------

You simply have to set a realURL configuration for each (different)
sub-domain. Usually you have defined:

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']

which is enough for one-domain sites, or for the default domain. But in
multi-domain setups you simply have to add an entry in the realURL
config for every domain. If you want to save some bytes of memory you
could of course use "references" (see PHP manual):

----------------------------
$tx_realurl_config = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname1.com']=$tx_realurl_config;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domainname1.com']=&$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname1.com'];

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname2.tld']=$tx_realurl_config;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domainname2.tld']=&$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname2.tld'];

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname1.com']['pagePath']['rootpage_id']=1;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname2.tld']['pagePath']['rootpage_id']=4;

unset($tx_realurl_config);
-----------------------------

Just note the "&" before the defintion for "domainname1.com" (without
www prefix) - using the "&" operator when assigning a variable, you do
not create a copy of the variable - but rather just set a reference to
it. So the array keys "www.domainname1.com" and "domainname1.com" both
point to the same array/configuration.

So in this case (when using references) you only need to set the
pagePath/rootpage_id variable once for each entry:
$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domainname2.tld']['pagePath']['rootpage_id']=4;
as the contents of array key "www.domainname2.tld" is the same as
"domainname2.tld" ...

I hope this is clear ...




> Last things that I have done is to put a .htaccess 301 redirect in the
> www.domainname2.com to www.domainname1.com/index.php?id=4

I don't think this is necessary ...


> Where I get confuse is:
> - how the domain record should used in this context?

Just put a domainrecord "www.domainname2.tld" onto the root-page of this
site (on page with id=4).
And if you want the domain to get recognized as "domainname2.tld" also -
and not only WITH the "www." prefix - then simply add a second domain
record with "domainname2.tld" - it should be below the primary domain
record.



greets,
Bernhard


More information about the TYPO3-english mailing list