Home > Blockchain >  Refresh header redirect fails - "the scheme does not have a registered handler"
Refresh header redirect fails - "the scheme does not have a registered handler"

Time:12-13

I don't know how to debug this problem... I'm trying to do a redirect with a header:

header('Refresh:5;Location:https://www.google.com/);
exit();

but I get the following error:

Failed to launch 'location:https://www.google.com/' because the scheme does not have a registered handler.

Now I understand that this is related to whether I have sent some output on the screen... but in my case I have verified that it was not with the following example:

ob_start();

$validate = ob_get_contents();

ob_end_clean();

var_dump(mb_strlen($validate));

the result is:

**0**

how do i know it might be related to other header use:

var_dump(headers_list());

the result is:

array(4) {
  [0]=>
  string(24) "X-Powered-By: PHP/7.4.28"
  [1]=>
  string(38) "Expires: Thu, 19 Nov 1981 08:52:00 GMT"
  [2]=>
  string(50) "Cache-Control: no-store, no-cache, must-revalidate"
  [3]=>
  string(16) "Pragma: no-cache"
}

Questions:

  1. Is the error due to having established the session? Do I understand that the header or the list of the header is due to having established the session?

  2. I don't see how to solve the problem... it's not 1 or 2 or 3 files, it's a lot of files before reaching the redirector?

NOTE: I'm trying to use mandatory header, it shouldn't use meta tag or javascript.

CodePudding user response:

This error is not related to header or sending headers or web browser.

Actually, the two questions that a php developer can ask you should be discarded since the problem is a bad documentation in php.

For redirect you must use url instead of Location:

header('Refresh:5;url:https://www.google.com/);

this is not properly documented on the PHP page, but can be found in a comment below.

https://www.php.net/manual/en/function.header.php

https://www.php.net/manual/en/function.header.php#97114

  • Related