Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 重定向到在www Wamp文件夹中动态创建的本地网页_Php_File_Redirect_Wamp_Webpage - Fatal编程技术网

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

Php 重定向到在www Wamp文件夹中动态创建的本地网页,php,file,redirect,wamp,webpage,Php,File,Redirect,Wamp,Webpage,我使用上面的PHP代码在www文件夹中使用Wamp创建了一个本地页面,我想重定向到这个页面,但是带有header的重定向不起作用 我得到的信息是: 页面未正确重定向 Firefox检测到服务器正在以一种永远无法完成的方式重定向对此地址的请求。此问题有时可能是由于禁用或拒绝接受Cookie造成的 有人知道怎么做吗 我的代码: $myFileName_with_no_lower_case = 'website_name'.$job.$ville; $myFileName = strt

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

我得到的信息是:


页面未正确重定向

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

这是您的解决方案,我的工具箱中的faverite函数之一:)

/==重定向。。。请尝试PHP头重定向,然后尝试Java重定向,然后尝试http重定向:
函数重定向($url)
{
如果(!headers_sent())
{//如果尚未发送头…则执行php重定向
标题('位置:'。$url);
出口
}否则
{//如果发送了头…执行java重定向…如果禁用java,执行html重定向。
回声';
echo'window.location.href=“”.$url.“;”;
回声';
回声';
回声';
回声';
出口
}
}//==结束--重定向
现在可以工作了:

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

@佩卡,你说得对,谢谢!但现在我遇到了另一个问题(相关的,所以我不会改变帖子)。谢谢你的回答,但我得到了和往常一样的消息。页面没有正确重定向。Firefox检测到服务器正在以一种永远无法完成的方式重定向对此地址的请求。此问题有时可能是由于禁用或拒绝接受cookiesuse导致的。如果(file_exists($myFileName)){header here}或者{echo'file not exists';}以确保您的文件确实存在,请使用。还可以尝试从地址栏访问该文件,以确保该文件可以通过web访问(不应该是wamp上的问题)哦,这是一个恼人的错误。。。您正在重定向到同一页。。无限循环。如果您需要重定向到同一个文件,请执行一个特殊的操作,克服重定向,这样在重定向后您就不会被重定向。我已经检查了文件夹,并且该文件存在。当我尝试用地址栏访问它时,我收到了相同的消息。
    $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);