News Archive
PhpRiot Newsletter
Your Email Address:

More information

Typo3: Configurable <base href="..."/> URL

Note: This article was originally published at Planet PHP on 2 February 2011.
Planet PHP

When using RealURL in Typo3, I prefer to set a in the page since that makes generating links and linking CSS and JavaScript files much easier - and many extensions do not care about adding a / prefix to their links.

The TypoScript setup is easy:

config.baseURL =

Problem with this solution is that it works for a single host only and fails badly when having different systems - the developer machine and the live server. Now you have to remember setting up the URL on all systems correctly and do that on every change.

A better solution is to set the base URL automatically, depending on the current host header.

TypoScript constants:

BASEURL = [globalString =] BASEURL = [globalString =] AND [globalString =_SERVER|HTTPS=on] BASEURL = [global]

TypoScript setup:

config.baseURL = {$BASEURL}