Our server uses https, but when we want to redirect to an external site that uses http, the https still gets added on. We will often have mixed links where some links are http and some are https. Our current call goes as:

drupal_goto($link, array("external" => TRUE));//where $link is the link we want to redirect to

Is setting the https option to false the way to go, or will it kill the links that should be https? I would think for an external link that drupal would not be trying to change that.

We changed the code to this, but it did not fix the issue:

$parsed = parse_url($link);
if ($parsed["scheme"] === "http") {
  $https = FALSE;
else {
  $https = TRUE;
// Forward to requested URL.
drupal_goto($link, ["external" => TRUE, "https" => $https]);

1 Answer 1


drupal_goto() takes a $path and $options which in turn sends them to url(). As you can see in the docs for url()


'https': Whether this URL should point to a secure location. If not defined, the current scheme is used, so the user stays on HTTP or HTTPS respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can only be enforced when the variable 'https' is set to TRUE.

so in your case the redirects will be https by default, which means you will have to set the them individually each time to use only http e.g.

drupal_goto($path, array("external" => TRUE, "https" => FALSE));
  • But shouldn't the code that I provided (parsing for the scheme the link) and using FALSE where it is http do what you have suggested? Currently it is not.
    – shelane
    May 15, 2015 at 19:23
  • Is your $path already an external https URL ? May 16, 2015 at 10:41
  • No, it's the links that are http only that are the ones causing the problem. They're still getting https added to them. The https links come out with https also - which is fine of course.
    – shelane
    May 17, 2015 at 1:49

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.