重定向到在Wamp文件夹中动态创建的本地网页


Redirect to a local webpage created dynamically in www Wamp folder

我使用上面的PHP代码在www文件夹中使用Wamp创建了一个本地页面,我想重定向到这个页面,但是带头的重定向不起作用。

我得到消息:

页面没有正确重定向。

Firefox检测到服务器正在以一种永远不会完成的方式重定向此地址的请求。此问题有时可能由禁用或拒绝接受cookie引起

有人知道怎么做吗?

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_paste.php');
    fwrite($myFileHandle,$file_content);
    fclose($myFileHandle);
    // eveything works fine until now
    header("Location:".$myFileName);

这是你的解决方案,在我的工具箱中我最喜欢的功能之一:)

//==== 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

现在运行:

    $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);