Is it possible to display the full, absolute URL of the home page in Drupal 7, like www.example.com/The-best-example-possible ?
I'd like to display the full URL of the home page, not just the hostname.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
In Drupal 7, The front page is normally set via
system_site_information_settings(). It is an unaliased URL, so it is best to use the API. I would do it as:
$home = url(variable_get('site_frontpage', 'node'), array('absolute' => TRUE));
In Drupal 8, there is a special route
<front> that you can use with the
use \Drupal\Core\Url; $home = Url::fromRoute('<front>')->setAbsolute()->toString();
However, in most circumstances you don't need to explicitly render out
Url() objects as strings; you can just use the object itself.
global $conf, $base_url; echo $base_url . '/' . variable_get('site_frontpage', 'node');