PHP URL redirection

<?php
$url = 'http://onestopweb.iteye.com/#onestopweb';
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a href="http://demo.com/bridge.php?url=<?php echo $url;?>">One ​​stop for internet focus</a>
</body>
</html>

 

<?php
//set mark
$flag = '0';
//Determine whether to pass parameters through GET
if (is_array($_GET) && count($_GET) > 0) {
    / / Determine whether there is a url parameter
    if (isset($_GET['url'])) {
        //Check if the parameter is empty
        if(empty($_GET['url'])){
            $flag = '3';
        }else{
            $url = $_GET['url'];
            $flag = '1';
        }
    }else{
        $flag = '2';
    }
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>URL redirection</title>
<?php
if($flag=='1'){
    //PHP jump
    Header("Location: $url");
    //HTML jump
    echo "<META HTTP-EQUIV='REFRESH' CONTENT='0; URL=$url'>";
    //JS jump
    echo "<SCRIPT LANGUAGE=\"JavaScript\">location.href='$url'</SCRIPT>";
}
?>
</head>
<body>
<?php
if($flag=='1'){ //Display page that cannot be redirected
    echo 'Please copy and open'.$url;
}else if($flag=='2'){
    echo 'The parameter is incorrect';
}else if($flag=='3'){
    echo 'The parameter cannot be empty';
}else{ //Display page without GET
    echo 'This page cannot be displayed';
}
?>
</body>
</html>

 

Effect picture:

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326050393&siteId=291194637