最近有需求将 INX Git 上的内容转到微信,鉴于微信及其积极的扫描政策,我决定主动屏蔽微信来避免潜在的风险。
Blog 端规则
首先,由于我有博客,所以我索性就直接托管在这里了,毕竟进行 CVS 之类的很方便。
创建一个 wechat.html。随便写点内容,例如,你可以看看我的超简陋版。
加入一段 javascript 代码,实现点击在浏览器中打开自动跳转。
1 | var originalUrl = window.location.hash.substr(1); |
随后,在 _config.yml 中,include字段下加入 wechat.html, skip_render字段下加入wechat.html。
随后正常部署即可。
Cloudflare 端规则
由于我的博客使用 Cloudflare,因此可以直接创建一条重定向规则,其中条件为
1 | (http.user_agent contains "MicroMessenger" and not starts_with(http.request.full_uri, "https://inx.wf/wechat.html")) or (http.user_agent wildcard r"MicroMessenger|WeiXin" and not starts_with(http.request.full_uri, "https://inx.wf/wechat.html")) |
动作为动态 301 跳转到 concat("https://inx.wf/wechat.html#", http.request.full_uri)