Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

david19's avatar

(PHP) After unzip redirect

Hello Team. With this php, i will unzip my laravel folders. But after this, i will redirect to a other php file. The redirect doesnt work :(

<?php



$file = 'my-dev.zip'; //Dateiname entsprechend �ndern

$path = pathinfo(realpath($file), PATHINFO_DIRNAME);

$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
  $zip->extractTo($path);
  $zip->close();
  
header('/install.php');

} else {
  echo "Die Datei $file konnte nicht gefunden/ge&ouml;ffnet werden.";
}

exit;
?>
0 likes
6 replies
Sinnbeck's avatar

I believe it should be

header("Location: /install.php");
1 like
david19's avatar

Its not work :( After unzip all files, stands on the current site :( Maby its the .htaccess?

RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/ [L]
david19's avatar

Sorry its not work :( Yes i can access the url manually.

<?php
$file = 'my-dev.zip';
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
  $zip->extractTo($path);
  $zip->close();
  
header("Location: http://localhost/install.php");

} else {
  echo "Die Datei $file konnte nicht gefunden/ge&ouml;ffnet werden.";
}
exit;
?>

I dont understand :(

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Does it work if you just place this at the very top (after <?php)

header("Location: http://localhost/install.php");
1 like

Please or to participate in this conversation.