PHP:头重定向无法重定向到其他文件夹中的文件
当我试图重定向到包含代码的文件所在的同一目录之外的文件时,头重定向不起作用。代码在PHP:头重定向无法重定向到其他文件夹中的文件,php,redirect,Php,Redirect,当我试图重定向到包含代码的文件所在的同一目录之外的文件时,头重定向不起作用。代码在iar calculator.php文件下,代码在第二个elseif下工作,但由于其他两个文件位于不同的目录或文件夹中。我试着使用。/foldername/page.php,`foldername/page.php`。在我的情况下,两者都不起作用。我怎样才能修好它?谢谢 if(isset($_POST['cmd_submit'])){ if(($_POST['tire'] == "rear") &&
iar calculator.php
文件下,代码在第二个elseif
下工作,但由于其他两个文件位于不同的目录或文件夹中。我试着使用。/foldername/page.php
,`foldername/page.php`。在我的情况下,两者都不起作用。我怎样才能修好它?谢谢
if(isset($_POST['cmd_submit'])){
if(($_POST['tire'] == "rear") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:iar-calculator.php');
}
elseif(($_POST['tire'] == "rear") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:index.php');
}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:front/index.php');}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:front/iar-calc-rear.php');
}
else{
}
}
//重定向
if(isset($_POST['cmd_submit'])){
if(($_POST['tire'] == "rear") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:iar-calculator.php');
}
elseif(($_POST['tire'] == "rear") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:index.php');
}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:front/index.php');}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:front/iar-calc-rear.php');
}
else{
}
}
//HTML代码
if(isset($_POST['cmd_submit'])){
if(($_POST['tire'] == "rear") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:iar-calculator.php');
}
elseif(($_POST['tire'] == "rear") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:index.php');
}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:front/index.php');}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:front/iar-calc-rear.php');
}
else{
}
}
<form method="post" style="padding: 10px 0px 10px 5px;">
<select name="tire" style="width:100px;display:inline;height: 30px;" class="first">
<option value="">Select</option>
<option value="rear">Rear Tire</option>
<option value="front">Front Tire</option>
</select>
<select name="tractor" style="width:100px;height: 30px;display:inline" class="second" disabled>
<option value="">select Type</option>
<option value="2wd">2WD</option>
<option value="mfwd">MFWD</option>
<option value="4wd">4WD</option>
</select>
<input type="submit" value="Go" name="cmd_submit" />
页眉函数必须在加载页面中的第一个。加
if(isset($_POST['cmd_submit'])){
if(($_POST['tire'] == "rear") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:iar-calculator.php');
}
elseif(($_POST['tire'] == "rear") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:index.php');
}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:front/index.php');}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:front/iar-calc-rear.php');
}
else{
}
}
ob_start();
第一线
if(isset($_POST['cmd_submit'])){
if(($_POST['tire'] == "rear") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:iar-calculator.php');
}
elseif(($_POST['tire'] == "rear") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:index.php');
}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:front/index.php');}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:front/iar-calc-rear.php');
}
else{
}
}
<?php
头函数必须在加载页面中的第一个。加
if(isset($_POST['cmd_submit'])){
if(($_POST['tire'] == "rear") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:iar-calculator.php');
}
elseif(($_POST['tire'] == "rear") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:index.php');
}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:front/index.php');}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:front/iar-calc-rear.php');
}
else{
}
}
ob_start();
第一线
if(isset($_POST['cmd_submit'])){
if(($_POST['tire'] == "rear") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:iar-calculator.php');
}
elseif(($_POST['tire'] == "rear") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:index.php');
}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:front/index.php');}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:front/iar-calc-rear.php');
}
else{
}
}
<?php
您正在设置一个HTTP头,它的内容应该是一个有效的、完全限定的URL。@miken32很抱歉,我不知道该放在哪里?我是说您需要一个完整的URL。@miken32我也厌倦了,运气不好。我尝试使用标题(“位置:http://www.google.com/"); /* 重定向浏览器*/}
这仍然不起作用可能重复您正在设置HTTP头,其内容应该是有效的完全限定的URL。@miken32很抱歉我没有得到它我应该把它放在哪里?我是说您需要一个完整的URL。@miken32我也厌倦了,运气不好。我尝试使用标题(“位置:http://www.google.com/"); /* 重定向浏览器*/}
这仍然不起作用可能重复
if(isset($_POST['cmd_submit'])){
if(($_POST['tire'] == "rear") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:iar-calculator.php');
}
elseif(($_POST['tire'] == "rear") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:index.php');
}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "2wd" || $_POST['tractor'] == "4wd")){
//redirect here
header('location:front/index.php');}
elseif(($_POST['tire'] == "front") && ($_POST['tractor'] == "mfwd")){
//redirect here
header('location:front/iar-calc-rear.php');
}
else{
}
}