I can't get php version 8.0 redirect to work in Visual Studio Code

142 Views Asked by At

I have used this same code PHP redirect on a hosting site and it works fine. When I use it in Visual Studio Code with my localhost setup, it doesn't work. In PHP version 8.0 I do a

$reroutePath = "Location: http://" . $_SERVER['HTTP_HOST'] . "/test.php";
header($reroutePath);

The path is: http://localhost/test.php I have tried everything including the use of ob_start(), ob_flush(), ob_clean() before doing the header($reroutePath) and still get no reroute.

When I use the step debug in Visual Studio Code, everything works correctly but nothing occurs when it executes the header($reroutePath) code line.

Is there something I need to change or put in the php.ini-development file. I am using PHP version 8.0 in Visual Studio Code on Windows 10. This is the only problem I have ever had with my localhost PHP setup. I have the output_buffering = 4096 uncommented in my php.ini-development file. I would appreciate any help or advice.

0

There are 0 best solutions below