Redirect to a local webpage created dynamically in www Wamp folder
I use the PHP code above to create a local page using Wamp in the www folder and I'd like to redirect to this page but the redirection with header doesn't work.
I get the message :
The page isn't redirecting properly.
Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies
Does someone know how to do this ?
my code :
$myFileName_with_no_lower_case = 'website_name'.$job.$ville;
$myFileName = strtolower($myFileName_with_no_lower_case);
$myFileHandle = fopen($myFileName, 'w') or die("can't open file");
$file_content = file_get_contents('./file_with_content_i_want_to_p开发者_如何转开发aste.php');
fwrite($myFileHandle,$file_content);
fclose($myFileHandle);
// eveything works fine until now
header("Location:".$myFileName);
this is your solution, one of my faverite functions in my toolbox :)
//==== Redirect... Try PHP header redirect, then Java redirect, then try http redirect.:
function redirect($url)
{
if (!headers_sent())
{ //If headers not sent yet... then do php redirect
header('Location: ' . $url);
exit;
} else
{ //If headers are sent... do java redirect... if java disabled, do html redirect.
echo '<script type="text/javascript">';
echo 'window.location.href="' . $url . '";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
echo '</noscript>';
exit;
}
} //==== End -- Redirect
Works now :
$myFileName_with_no_lower_case = $job.$ville;
$myFileName = strtolower($myFileName_with_no_lower_case);
$myFileHandle = fopen($myFileName, 'w') or die("can't open file");
$file_content = file_get_contents('./formulaire_artisans.php');
fwrite($myFileHandle,$file_content);
fclose($myFileHandle);
header("Location:".$myFileName);
精彩评论