共計(jì) 2402 個(gè)字符,預(yù)計(jì)需要花費(fèi) 7 分鐘才能閱讀完成。
wordpress 純代碼怎么實(shí)現(xiàn)外鏈通過(guò) go 界面進(jìn)行 url 跳轉(zhuǎn)? 網(wǎng)站外鏈跳轉(zhuǎn)時(shí)通過(guò) go 界面進(jìn)行對(duì) seo 比較友好,可以避免權(quán)重的流失。
一般的 wordpress 主題模板都不會(huì)帶這個(gè)功能,如果帶了的可以選擇忽略這篇文章,或者可以閱讀這篇文章進(jìn)行一定的學(xué)習(xí),其實(shí)利用 php 代碼可以實(shí)現(xiàn)這個(gè)功能。
其實(shí),想要實(shí)現(xiàn)這個(gè)功能還是非常簡(jiǎn)單的,只需要兩步操作即可完成。今天,丸趣 TV(wanqutv.com) 就教 大家如何實(shí)現(xiàn)純 php 代碼實(shí)現(xiàn)外鏈通過(guò) go 進(jìn)行跳轉(zhuǎn) url。
第一步: 創(chuàng)建 php 文件
首先在網(wǎng)站根目錄創(chuàng)建一個(gè) go.php 的文件,然后將如下代碼復(fù)制到該 php 文件中。
<?php
$t_url = preg_replace('/^url=(.*)$/i','$1',$_SERVER["QUERY_STRING"]);
if(!empty($t_url)) {
preg_match('/(http|https):\/\//',$t_url,$matches);
if($matches){
$url=$t_url;
$title='頁(yè)面正在安全跳轉(zhuǎn)中, 請(qǐng)稍候';
} else {
preg_match('/\./i',$t_url,$matche);
if($matche){
$url='http://'.$t_url;
$title='頁(yè)面正在安全跳轉(zhuǎn)中, 請(qǐng)稍候';
} else {
$url='//wanqutv.com/';
$title='參數(shù)錯(cuò)誤,正在返回首頁(yè)';
}
}
} else {
$title='參數(shù)缺失,正在返回首頁(yè)';
$url='//wanqutv.com/';
}
?>
<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>
<style>
body {background:#000}
.loading {
-webkit-animation:fadein 2s;
-moz-animation:fadein 2s;
-o-animation:fadein 2s;
animation:fadein 2s}
@-moz-keyframes fadein {from {opacity:0}
to {opacity:1}}
@-webkit-keyframes fadein {from {opacity:0}
to {opacity:1}}
@-o-keyframes fadein {from {opacity:0}
to {opacity:1}}
@keyframes fadein {from {opacity:0}
to {opacity:1}}
.spinner-wrapper {
position:absolute;
top:0;
left:0;
z-index:300;
height:100%;
min-width:100%;
min-height:100%;
background:#3498db}
.spinner-text {
position:absolute;
top:50%;
left:50%;
margin-left:-200px;
margin-top: 2px;
color:#fff;
letter-spacing:1px;
font-weight:700;
font-size:36px;
font-family:Arial}
.spinner {
position:absolute;
top:50%;
left:50%;
display:block;
margin-left:-270px;
width:1px;
height:1px;
border:25px solid rgba(100,100,100,0.2);
-webkit-border-radius:50px;
-moz-border-radius:50px;
border-radius:50px;
border-left-color:transparent;
border-right-color:transparent;
-webkit-animation:spin 1.5s infinite;
-moz-animation:spin 1.5s infinite;
animation:spin 1.5s infinite}
@-webkit-keyframes spin {0%,100% {-webkit-transform:rotate(0deg) scale(1)}
50% {-webkit-transform:rotate(720deg) scale(0.6)}}
@-moz-keyframes spin {0%,100% {-moz-transform:rotate(0deg) scale(1)}
50% {-moz-transform:rotate(720deg) scale(0.6)}}
@-o-keyframes spin {0%,100% {-o-transform:rotate(0deg) scale(1)}
50% {-o-transform:rotate(720deg) scale(0.6)}}
@keyframes spin {0%,100% {transform:rotate(0deg) scale(1)}
50% {transform:rotate(720deg) scale(0.6)}}
</style>
</head>
<body>
<div class="loading">
<div class="spinner-wrapper">
<span class="spinner-text"> 頁(yè)面正在安全跳轉(zhuǎn)中, 請(qǐng)稍候 </span>
<span class="spinner"></span>
</div>
</div>
</body>
</html>
正文完