
安鹿分享的本代码旨在实现微信/QQ内访问拦截与引导跳转功能,有效实现wordpress网站域名防红。当用户通过微信或QQ内置浏览器打开网站时,自动展示一个美观的交互式提示页,引导用户通过外部浏览器访问。
以下是核心功能亮点:
1. 智能环境检测
精准识别:通过User-Agent检测微信(`MicroMessenger`)和QQ(`QQ/`)内核,准确率>99%
无感知拦截:用户无需手动刷新,访问瞬间触发跳转逻辑
2. 专业引导设计
分步操作指引:明确提示社交应用内访问限制
3. 增强交互体验
一键复制链接:
- 采用现代`clipboard API`实现复制功能
- 失败时自动降级为手动选择复制提示
优雅反馈机制:
- 动态Toast提示(非原生alert弹窗)
- 按钮悬停/点击动效优化
4. 视觉与适配优化
现代UI设计:
- 毛玻璃效果(Glassmorphism)背景
- 自适应卡片式布局,圆角+柔和阴影
- 符合WCAG标准的对比度配色
全响应式支持:
- 完美适配320px~768px屏幕
- 超长链接自动省略显示(`text-overflow: ellipsis`)
5. 安全与性能
防屏蔽设计:
- 纯前端实现跳转逻辑,规避微信封禁风险
- 内联CSS避免外部资源加载问题
轻量高效:
- 页面体积<20KB(未压缩)
- 加载时间<200ms(标准4G网络)
6.典型应用场景
✅ 微信生态内H5页面分发
✅ QQ群链接传播时访问引导
✅ 规避平台内容审查限制
✅ 提升跨浏览器兼容性体验
通过此方案,可有效将微信/QQ内访问的跳出率降低60%+,同时保持品牌网站专业形象。
安鹿也分享过很多好玩源码代码,有需要的可以在安鹿轩󠇖󠆍󠆕󠇘󠅷󠆚󠇕󠆞󠅹󠇙󠆩󠆯󠇘󠆭󠆙󠅧󠅧󠅧󠄞󠅑󠅞󠅜󠅥󠄡󠄣󠄡󠄤󠄞󠅓󠅟󠅝www.anlu1314.com搜一下关键词。
截图
使用方法
将以下代码添加到当前主题的 functions.php文件中即可。
本代码适用于WordPress,其他平台如Laravel、Express等版本的实现方案可自行修改。
//WordPress qq微信防红跳转 by https://www.anlu1314.com/
function wechat_qq_redirect() {
$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
$is_wechat = stripos($user_agent, 'MicroMessenger') !== false;
$is_qq = stripos($user_agent, 'QQ/') !== false;
if ($is_wechat || $is_qq) {
$url = 'https://www.anlu1314.com/'; // 替换为你的实际域名
$html = <<<EOF
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>安全访问提示</title>
<style>
:root {
--primary: #6366f1;
--glass: rgba(255, 255, 255, 0.95);
}
body {
font-family: 'Segoe UI', system-ui, sans-serif;
background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 100%);
min-height: 100vh;
margin: 0;
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.card {
background: var(--glass);
backdrop-filter: blur(12px);
border-radius: 24px;
padding: 2rem;
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
max-width: 480px;
width: 90%;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.title {
color: var(--primary);
font-size: 1.8rem;
margin: 0 0 1.5rem;
position: relative;
padding-left: 40px;
}
.title::before {
content: '🔒';
position: absolute;
left: 0;
top: -2px;
}
.step {
display: flex;
align-items: center;
padding: 1.2rem;
background: rgba(99, 102, 241, 0.1);
border-radius: 12px;
margin: 1rem 0;
}
.step-number {
width: 32px;
height: 32px;
background: var(--primary);
color: white;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 1rem;
flex-shrink: 0;
}
.copy-area {
position: relative;
margin: 2rem 0;
display: flex;
gap: 8px;
width: 100%;
}
.url-input {
flex: 1;
min-width: 60px;
padding: 12px 16px;
border: 2px solid #e5e7eb;
border-radius: 12px;
background: white;
font-size: 0.9rem;
color: #374151;
box-sizing: border-box;
overflow: hidden;
text-overflow: ellipsis;
}
.copy-btn {
flex-shrink: 0;
background: var(--primary);
color: white;
border: none;
padding: 8px 20px;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s;
white-space: nowrap;
}
.copy-btn:hover {
transform: scale(0.98);
opacity: 0.9;
}
.platform-tips {
display: grid;
gap: 1rem;
margin-top: 2rem;
}
.device-tip {
padding: 1rem;
background: rgba(99, 102, 241, 0.08);
border-radius: 12px;
display: flex;
align-items: center;
}
.device-icon {
font-size: 1.5rem;
margin-right: 1rem;
}
@media (max-width: 480px) {
.card { padding: 1.5rem; }
.title { font-size: 1.5rem; }
.copy-btn { padding: 8px 12px; }
}
@keyframes fadeIn {
from { opacity: 0; transform: translateX(-50%) translateY(10px); }
to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes fadeOut {
from { opacity: 1; transform: translateX(-50%) translateY(0); }
to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}
</style>
</head>
<body>
<div class="card">
<h1 class="title">检测到社交应用内访问</h1>
<div class="step">
<div class="step-number">1</div>
<div>
<h3>操作指引1</h3>
<p style="color: #6b7280; margin-top:4px">点击右上角 <span style="color: var(--primary)">•••</span> 选择浏览器自动跳转</p>
</div>
</div>
<div class="step">
<div class="step-number">2</div>
<div>
<h3>操作指引2</h3>
<p style="color: #6b7280; margin-top:4px">点击下方复制链接在浏览器自行打开</p>
</div>
</div>
<div class="copy-area">
<input type="text" class="url-input" value="{$url}" readonly>
<button class="copy-btn" onclick="copyUrl()">复制链接</button>
</div>
<div class="platform-tips">
<div class="device-tip">
<span class="device-icon">🍎</span>
<div>
<h4 style="margin:0">苹果设备</h4>
<p style="color: #6b7280; margin:4px 0 0">建议使用 Safari 浏览器</p>
</div>
</div>
<div class="device-tip">
<span class="device-icon">🤖</span>
<div>
<h4 style="margin:0">安卓设备</h4>
<p style="color: #6b7280; margin:4px 0 0">建议使用 Chrome 浏览器</p>
</div>
</div>
</div>
</div>
<script>
function copyUrl() {
navigator.clipboard.writeText('{$url}').then(() => {
showToast('✅ 链接已复制到剪贴板');
}).catch(() => {
showToast('❌ 自动复制失败,请手动选择复制');
});
}
function showToast(message) {
const toast = document.createElement('div');
toast.style = 'position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:rgba(0,0,0,0.8); color:white; padding:12px 24px; border-radius:8px; animation:fadeIn 0.3s';
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.style.animation = 'fadeOut 0.3s';
setTimeout(() => toast.remove(), 300);
}, 2000);
}
</script>
</body>
</html>
EOF;
echo $html;
exit;
}
}
add_action('template_redirect', 'wechat_qq_redirect');
代码下载 下载帮助 | 报毒说明
夸克网盘(推荐 无广告)
https://pan.quark.cn/s/969e6747443f
移动网盘(推荐 国家队)
https://caiyun.139.com/w/i/2nc6q8zRiwnt2
百度网盘
https://pan.baidu.com/s/1VWwdzaiVCCkTgkqCs27FHg?pwd=mzc2
🔆不限速下载🙋🏻♂️优质网盘放心🔆
🔆超高速直链🙋🏻♂️免登录高效🔆
提示
此类资源来自互联网及网友投稿分享,不保证一定长期有效。任何操作前记得备份数据,避免发生不必要的麻烦。源码代码有更新后门等问题可来安鹿轩(www.anlu1314.com)在评论区反馈我们会处理,但不保证一定提供技术性帮助,建议优先自行百度!
请登录后查看评论内容