Our live environment is over SSL, but our local sandboxes aren't. This requires us to use {file:secure_url} in our exp:channel_files:files tag pair. Is there a way to output this URL that will inherit the protocol currently in use? Or a way to get the URL without the protocol or domain? I didn't see them in the docs.

The other issue I'm seeing is that the {file:secure_url} and {file:url} tags are outputting a URL to the live (.com) site domain on my local sandbox which is (.dev) - I don't see how that is possible, looking in the channel_files table. Any thoughts on that?

  • I am getting a similar issue but in strange conditions of Page loads fine http links but if you come from google it changes the channel_file urls to https. We dont have https set up so it breaks Commented Jan 22, 2015 at 1:43

2 Answers 2


I might be missing something here, but in your Control Panel > Administration > General Configuration page, just set the URL to the root directory of your site setting to:


(replacing that with your site URL)

Same for the URL to your "themes" folder setting.

Using the double-slash with no http prefix means that it is protocol agnostic and accepts https:// and http://. Your webserver does the rest.


This doesn't quite answer your specific question, but it might help anyway.

Normally when I've done SSL sites, which also haven't had local sandboxes serving SSL, I just use the config file to set the base URL and site URL conditionally with or without the https.

Focus Lab's Master Config already does this automatically. (excerpted below)

$protocol                          = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
$base_url                          = $protocol . $_SERVER['HTTP_HOST'];
$base_path                         = $_SERVER['DOCUMENT_ROOT'];
$system_folder                     = APPPATH . '../';
$images_folder                     = 'images';
$images_path                       = $base_path . '/' . $images_folder;
$images_url                        = $base_url . '/' . $images_folder;

$env_config['index_page']          = '';
$env_config['site_index']          = '';
$env_config['base_url']            = $base_url . '/';
$env_config['site_url']            = $env_config['base_url'];
$env_config['cp_url']              = $env_config['base_url'] . 'admin.php';
$env_config['theme_folder_path']   = $base_path   . '/themes/';
$env_config['theme_folder_url']    = $base_url    . '/themes/';
$env_config['emoticon_path']       = $images_url  . '/smileys/';
$env_config['emoticon_url']        = $images_url  . '/smileys/';
$env_config['captcha_path']        = $images_path . '/captchas/';
$env_config['captcha_url']         = $images_url  . '/captchas/';
$env_config['avatar_path']         = $images_path . '/avatars/';
$env_config['avatar_url']          = $images_url  . '/avatars/';
$env_config['photo_path']          = $images_path . '/member_photos/';
$env_config['photo_url']           = $images_url  . '/member_photos/';
$env_config['sig_img_path']        = $images_path . '/signature_attachments/';
$env_config['sig_img_url']         = $images_url  . '/signature_attachments/';
$env_config['prv_msg_upload_path'] = $images_path . '/pm_attachments/';

With something like this in place, you don't have to worry about relative paths, since the base path used for all path variables will include the correct protocol.

  • We do all that, which is why Channel Files' behavior was a little weird. I may have found the issue though...the client hardcoded file upload paths in the CP rather than setting them dynamically like this in the config. I'm thinking Channel Files cues off that regardless of the current URL and protocol. Commented Sep 17, 2014 at 13:14
  • Aha. It may also be possible that Channel Files isn't grabbing the settings from the right place (from the database instead of from the current config which could be database or config.php). Might be worth a support request. Commented Sep 17, 2014 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.