要隐藏第三方链接的原始地址,可以使用以下方法:

  1. 首先,在URL中添加一个参数,例如?url=原始链接地址,通过该参数传递原始链接地址。

  2. 使用正则表达式提取URL参数的值。

$t_url = preg_replace('/^url=(.*)$/i','$1',$_SERVER["QUERY_STRING"]);
  1. 检查是否存在有效的URL。
preg_match('/(http|https):\/\//',$t_url,$matches);
  1. 如果存在有效的URL,将其赋值给$url变量,并设置页面标题为"页面加载中,请稍候..."。
$url = $t_url;
$title = '页面加载中,请稍候...';
  1. 如果URL不是以"http://"或"https://"开头,添加"http://"前缀,并设置页面标题为"页面加载中,请稍候..."。
preg_match('/\./i',$t_url,$matche);
if($matche){
    $url = 'http://'.$t_url;
    $title = '页面加载中,请稍候...';
}
  1. 如果URL参数为空或不存在,设置页面标题为"参数缺失,正在返回首页...",并将URL设置为返回首页的链接。
$title = '参数缺失,正在返回首页...';
$url = 'https://www.csmjj.com/';
  1. 在HTML页面中,使用<meta http-equiv="refresh" content="1;url='<?php echo $url;?>';">标签进行页面跳转,并设置页面标题。
<meta http-equiv="refresh" content="1;url='<?php echo $url;?>';">
<title><?php echo $title;?></title>

通过以上方法,可以实现隐藏第三方链接的原始地址,并在页面加载中显示一个提示信息

php $t_url = preg_replace^url=$i$1$_SERVERQUERY_STRING; if!empty$t_url preg_matchhttphttps$t_url$matches; if$matches $url=$t_url; $title=页面加载中请稍候; else preg_matchi$t_url$matche; if$matche $url=http

原文地址: https://www.cveoy.top/t/topic/iVKx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录