Search code examples
.htaccessenvironment-variablesconditional-statementsrewriting

How to dynamically set the DefaultLanguage in htaccess?


Is it possible to set the DefaultLanguage in .htaccess according to an environmental variable or a rewrite condition?


Solution

  • You can use shell env variable in DefaultLanguage like this:

    DefaultLanguage ${_LANG}
    

    Where _LANG is the env variable set before Apache process has been started. I start my Apache as:

    sudo bash -c 'export _LANG=de && /Applications/MAMP/bin/startApache.sh'