Drupal - Get the site base url in template.php

You can use the base_path() function which should always work.

To be honest though it just returns $GLOBALS['base_path'] so your global $base_path statement should work fine.


base_path() only produce "/".

to get the full URL including the domain, you have to use: $GLOBALS['base_url']


If you want to get only the base URL, you can use the following line.

global $base_url;

I used it in many projects.

Tags:

Uri

Theming

7