Fully Qualified Domain Name and Base Path

Posted by Mr PHP on

This simple snippet will provide you with a HTTP or HTTPS Fully Qualified Domain Name URL and Base Path to your CakePHP installation. I use it for the HTML base tag.

Thanks to Nate for pointing out the best way to do this in CakePHP 1.2:

<base href="<?php echo Router::url("/", true); >" />

For historical purposes, here is the CakePHP 1.1 way of doing it.

<base href="<?php echo (env('HTTPS') ? 'https://' : 'http://') . env('HTTP_HOST') . $this->webroot; ?>" />

Tagged with : CakePHP