Search code examples
expressionengine

How can I access the hostname in an ExpressionEngine template


What's the easiest way to access the HTTP host name inside an ExpressionEngine template (without resorting to using PHP in the template).

Has a plugin already been created to do this, or should I use some sort of global variable?

Bonus points if there is a way to access other HTTP server variables inside an ExpressionEngine template as well.


Solution

  • You can set the hostname as a global variable and use that. You can set the global variable in your config file with php, and then you will have access to it in the template.

    Or you can use {path='site_index'}

    $assign_to_config['global_vars']['global_var_name'] = 'Global var value';