Set TYPO3_CONTEXT depending on domain

16 June 2020
htaccess

TYPO3 offers the possibility to use the Application Context to distinguish between Development, Testing and Production.
We can use this in different ways, I myself use for example: 

 

SetEnv TYPO3_CONTEXT Testing

 

in the .htaccess file to set the context.

If we now have fixed domains for all variants, we could take advantage of this and control the context dynamically.

If the context is set dynamically, we can use these domains for different scenarios, for example:

Testing and www are here a subdomain of naderio.de, whereas Development is a completely different Top Level Domain(TLD), namely .local. The local environment is provided by the local web server and exists only on the own computer.

Now we can use the .htaccess file to query which domain is used to access the website, and thus set the context:

 

SetEnvIf Host www\.naderio\.de$ TYPO3_CONTEXT=Production
SetEnvIf Host testing\.naderio\.de$ TYPO3_CONTEXT=Testing
SetEnvIf Host dev\.naderio\.local$ TYPO3_CONTEXT=Development

 

Now the TYPO3 installation should automatically have the correct context when you call the different domains.

Have fun testing
Thomas Anders

XS SM MD LG XL XXL