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

发布于 2024-12-02 04:56:56 字数 661 浏览 0 评论 0原文

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

我收到消息:

页面未正确重定向。

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

有人知道如何执行此操作吗?

我的代码:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野味少女 2024-12-09 04:56:56

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

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

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
沫离伤花 2024-12-09 04:56:56

现在工作:

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文