You are here

TYPO3 Multi-Domain-Hosting on IIS with wildcard subdomains

TYPO3Ever wanted to use wildcard subdomains with Microsoft Internet Information Services? You might have realized by now that this is actually not possible using only IIS as neither IIS 6 nor IIS 7 support the *.example.com notation.

The key to success is ISAPI_Rewrite, a third party ISAPI extension that brings mod_rewrite functionality to IIS. The latest version ISAPI_Rewrite 3 is compatible with Apache's mod_rewrite URL rewriting module which means that you can use the same rules you would use when hosting on Apache 2.

ISAPI_Rewrite Lite is available for free, but usually requires a more complex configuration as it does not support parsing of .htaccess files as the full version does. In this case, it doesn't matter since the following directions can either be placed inside the global configuration or inside an .htaccess file in your IIS default web.

RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [P,NC,QSA]

This uses the built-in ISAPI_Rewrite proxy to redirect all subdomains of example.com transparently to www.example.com. Your visitor will still see subdomain.example.com in his browser's address bar, just as if the subdomain was configured in the web that hosts www.example.com.

Now, for serving different contents from TYPO3, you need to tweak your configuration to make TYPO3 handle the HTTP_FORWARDED_HOST header sent by ISAPI_Rewrite.

To do this, you have to add the following lines to localconf.php:

$TYPO3_CONF_VARS['SYS']['reverseProxyIP'] = 'YOUR_SERVER_IP';
$TYPO3_CONF_VARS['SYS']['reverseProxyHeaderMultiValue'] = 'last';

This allows TYPO3 to handle proxy requests by ISAPI_Rewrite correctly.

You have to replace "YOUR_SERVER_IP" in the example above with the IP address of the server that is running ISAPI_Rewrite. This should normally be the IP address of the server that hosts example.com.

Once you did that, you can set up domains in TYPO3 as usual and ISAPI_Rewrite will take care of all the rest. No additional configuration is required.

Related Link: ISAPI_Rewrite 3

served by kangaroo.random-host.com