0
votes

I have TYPO3 (4.5) installed and a running project. The RealUrl extension is installed and enabled. Everything works as it should. For a proper user of the RealUrl extension i needed to add a few lines of code to the main template.

config.simulateStaticDocuments = 0
config.baseURL = http://www.example.com/
config.tx_realurl_enable = 1

Now i need access to the site by different sub-domains (eg "www1"). I tried the code below, but it is not working. I am not sure about the script i came up with.

host = example.com
[globalString = IENV:HTTP_HOST=www.example.com]
host = www.example.com
[globalString = IENV:HTTP_HOST=www1.example.com]
host = www1.example.com
[global]

config.simulateStaticDocuments = 0
config.baseURL= http://{$host}/
config.tx_realurl_enable = 1

Is this sufficient to keep the system running?

1
Are these different sites (with different root pages) or the same site with just 2 domains? In the first case, you should set up domain records on each site's root page, and you may (if required) define individual realurl-config for each domain wit RealURL's DOMAINS feature. Here is the most complex case I have, way more than you will probably need: stackoverflow.com/a/28472627/160968 . In the second case, you may prefer to 301 the second subdomain to the first one.Urs
This only one site. I just need it to be accessible from two subdomains. That's it. What do you think about my solution? Will there be any problems?user3897384
If you don't use a "canonical" tag, you may risk duplicate content penalizations from google, and you may need to register the second domain on web services like webfont providers. That's about it, I'd still rather do the 301 in the .htaccess, but I think it should work ok. Btw if your subdomain should have something to do with language, you can also do sth like [globalString = ENV:HTTP_HOST= www1.example.com] || [globalVar = GP:L = 1]Urs

1 Answers

0
votes

Variables need to be registered at the constant part of the template. TypoScript is no scripting language, but a treebuilding definition set. I suggest to skip variables alltogether and instead append the following to the end of your TypoScript.

config.baseURL = http://example.com
[globalString = IENV:HTTP_HOST=www.example.com]
config.baseURL = http://www.example.com
[globalString = IENV:HTTP_HOST=www1.example.com]
config.baseURL = http://www1.example.com
[global]

Additionally you should use config.absRefPrefix instead of config.baseURL.