Cześć, mam taką prostą metodę w PHP.
public function prepare(){
$myfile = fopen("x/$this->randomstr.php", "w") or die("Unable to open file!");
if(strpos($str,"http://" || "https://")){
$txt = "<?php header('Location: $this->link'); ?>";
}
else{
$txt = "<?php header('Location: http://$this->link'); ?>";
}
fwrite($myfile, $txt);
fclose($myfile);
$this->ready();
}
Nie wiedzieć dlaczego, php zapisuje plik o takiej treści
<?php header('Location: http://http://wp.pl'); ?>
Co w rezultacie daję taki adres http//wp.pl