用PHP内部重定向

时间:2015-10-11 13:53:32

标签: php meta

我有一个php文件。在其中我想要一个像这样的错误重定向:

<?php

$ponka = somerandomsite.com;

if (1=1)
    {echo '<META HTTP-EQUIV="Refresh" Content="0; URL=http://$ponka/error.php">'}
?>

我怎样才能实现它?

1 个答案:

答案 0 :(得分:2)

php包含很多错误,这是一个工作样本

<?php
$site = $_GET['site'] // will get the variable $site form a url like script.php?site=somerandomsite.com
$ponka = "somerandomsite.com";

if ($site == $ponka){
    echo "<META HTTP-EQUIV='Refresh' Content='0; URL=http://$ponka/error.php'>";
}
?>

此外,请将php视为名为header的函数

<?php
$site = $_GET['site'] // will get the variable $site form a url like script.php?site=somerandomsite.com
$ponka = "somerandomsite.com";
if ($site == $ponka){
   header("Location: http://$ponka/error.php");
}
?>