外链,顾名思义就是跳转到别的网站的链接。外链对于一个网站来说,其实是权重的流失,那么就需要对外链进行优化。
新建一个 go.php
文件到网站根目录,代码如下。记得把我网站的域名 huahai.club
改为自己网站的域名。
<?php
$t_url=$_GET['url'];
if(!empty($t_url)) {
preg_match('/(http|https):\/\//',$t_url,$matches);
if($matches){
$url=$t_url;
$title='页面跳转中,请稍候...';
} else {
preg_match('/\./i',$t_url,$matche);
if($matche){
$url='http://'.$t_url;
$title='页面跳转中,请稍候...';
} else {
$url='https://huahai.club/';
$title='参数错误,正在返回首页...';
}
}
} else {
$title='参数缺失,正在返回首页...';
$url='https://huahai.club/';
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="1;url='<?php echo $url;?>';">
<title><?php echo $title;?></title>
</head>
</html>
格式写为 https://自己网站域名/go.php?url=跳转链接
,比如要跳转到百度,那么就写为 https://huahai.club/go.php?url=www.baidu.com
。
可以看看实现效果:百度
Last modification:August 13th, 2019 at 08:49 pm