Fully Qualified Domain Name and Base Path

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; ?>" />

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Simpler alternative

There's a simpler alternative in 1.2: <?php echo Router::url("/", true); >

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

  • Allowed HTML tags: <b> <br> <p> <a> <strong> <cite> <em> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You may use [img:xx] tags to display uploaded files or images inline.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <css>, <diff>, <drupal5>, <html>, <javascript>, <php>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options