想要在url重定向到第三个url时隐藏第一个url


want to hide first url while URL redirecting to a 3rd url

有3个URL

我想在www.url1的页面中放置一个www.url2.com,并将其重定向到www.url3.com(脚本将在www.url2.com中)或当有人点击www.url1.com中的链接时,它会转到www.url2.com,php脚本会工作并重定向到www.url3.com

网站www.url3.com应该无法跟踪www.url1.com

www.url3.com应该只知道www.url2.com这是php脚本。请帮我想办法。

现在我在www.url1中放置了一个goo.gl(链接到www.url2.com)链接,并将用户带到www.url2,然后脚本将用户带至www.url3.com但是www.url3.com仍然显示源url为www.url1!!!它可以跟踪第一个url!!如何

<?php

// change if you wish
$db = 'urls.sw';
// language/style/output variables
$l_nourl        = '<strong>No URL supplied</strong>';
$l_yoururl      = '<strong>Your short url:</strong>';
$l_invalidurl   = '<strong>Invalid URL supplied.</strong>';
$l_createurl    = 'Snip!';

if(!is_writable($db) || !is_readable($db))
{
    die('Cannot write or read from file. Pleae CHMOD the url file to 777');
}
$action = trim($_GET['id']);
$action = (empty($action) || $action == '') ? 'create' : 'redirect';
$valid = "^(https?|ftp)':'/'/([a-z0-9+!*(),;?&='$_.-]+(':[a-z0-9+!*(),;?&='$_.-]+)?@)?[a-z0-9+'$_-]+('.[a-z0-9+'$_-]+)*(':[0-9]{2,5})?('/([a-z0-9+'$_-]'.?)+)*'/?('?[a-z+&'$_.-][a-z0-9;:@/&%=+'$_.-]*)?(#[a-z_.-][a-z0-9+'$_.-]*)?'$";
if($action == 'create')
{
    if(isset($_POST['create']))
    {
        $url = trim($_POST['url']);
        if($url == '')
        {
            echo $l_nourl;
        }
        else
        {
            if(eregi($valid, $url))
            {
                $fp = fopen($db, 'a');
                fwrite($fp, "{$url}'r'n");
                fclose($fp);
                $id = count(file($db));
                $dir = dirname($_SERVER['PHP_SELF']);
                $snippedurl = "http://{$_SERVER['HTTP_HOST']}{$dir}/$id";
                echo "$l_yoururl <a href='$snippedurl'>$snippedurl</a>";
            }
            else
            {
                echo $l_invalidurl;
            }
        }
    }
}
if($action == 'redirect')
{
    $urls = file($db);
    $id   = trim($_GET['id']);
    $id   = $id - 1;
    if(isset($urls[$id]))
    {
        header("Location: {$urls[$id]}");
        exit;
    }
}
?>

服务器无法设置客户端的HTTP引用程序。使用javascript代替

更改

header("Location: {$urls[$id]}");

echo "<script>location.href = '".$urls[$id]."';</script>";

适合您在此处获得其他javascript类型的重定向