易優(yōu)cms鏈接跳轉(zhuǎn)小插件,避免網(wǎng)站權(quán)重流失。
2023-01-15
易優(yōu)cms鏈接跳轉(zhuǎn)教程,避免輸出權(quán)重,可以先看下我們網(wǎng)站首頁的案例,點(diǎn)一下就明白了。

第一步:在application/home/controller新建一個(gè)php文件,名稱定為Jump.php,代碼如下:
<?php
namespace app\home\controller;
use think\Db;
class Jump extends Base
{
public function _initialize() {
parent::_initialize();
}
public function jump()
{
\think\Session::pause(); // 暫停session,防止session阻塞機(jī)制
$param = input('param.');
$aid = $param['aid'];
$url = Db::name('product_content')->where('aid',$aid)->getField('demourl');
$emptyhtml = <<<EOF
<!DOCTYPE html>
<html>
<head>
<title>網(wǎng)站即將跳轉(zhuǎn)</title>
<meta http-equiv="refresh" content="2;url={$url}" >
</head>
<body>
<p>請(qǐng)稍等,網(wǎng)站正在跳轉(zhuǎn)中...</p>
</body>
</html>
EOF;
return $emptyhtml;
}
}注意上面的這一句的兩個(gè)地方:
$url = Db::name('product_content')->where('aid',$aid)->getField('demourl');1、product_content中的product是指用的是產(chǎn)品模型,如果是文章模型做的跳轉(zhuǎn)則用article_content
2、demourl就是你的自定義字段。
第二步,輸出
首頁列表頁代碼:
a onclick="getUrlValue('{$field.aid}')" rel="nofollow">跳轉(zhuǎn)</a>詳情頁代碼:
a onclick="getUrlValue('{$eyou.field.aid}')" rel="nofollow">跳轉(zhuǎn)</a>同時(shí)在</body>前加上JS
script type="text/javascript">
function getUrlValue(aid) {
window.open('../index.php?m=home&c=Jump&a=jump&aid=' + aid, "_blank")
}
</script>如果有不明白的,可以聯(lián)系我喔。








