之前写过一篇关于404页面的:https://note.t4x.org/other/website-welfare-page/,最近把错误页面也准备https化。
腾讯404主要依赖于三个js:SourceByrd's Weblog-https://note.t4x.org/other/https-tencent-404/
http://www.qq.com/404/search_children.js
http://qzone.qq.com/gy/404/data.js
http://qzone.qq.com/gy/404/page.js SourceByrd's Weblog-https://note.t4x.org/other/https-tencent-404/
search_children.js:
0 1 2 3 |
[root@www js]# cat search_children.js var _base = 'https://error.t4x.org/js/'; document.write('<script type="text/javascript" src="'+ _base + 'data.js" charset="utf-8"></script>'); document.write('<script type="text/javascript" src="'+ _base + 'page.js" charset="utf-8"></script>'); |
其实就是两个js:
0 1 |
<script type="text/javascript" src="https://qzone.qq.com/gy/404/data.js" charset="utf-8"></script> <script type="text/javascript" src="https://qzone.qq.com/gy/404/page.js" charset="utf-8"></script> |
备注:data.js可以直接调用腾讯的:https://qzone.qq.com/gy/404/data.js,但是由于腾讯data.js里面图片是http,强迫症最好本地化一下。page修改下homepage然后本地化一下,直接用。
定时任务:将脚本加入定时任务,即可保证定时更新了。
0 1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/bin/bash # Author:Byrd # Version:0.1 # Site:note.t4x.org # Contact:root#t4x.org Site_Dir="/www/js" Get_Url="https://qzone.qq.com/gy/404/data.js" if [ -f ${Site_Dir}/data.js ]; then cd $Site_Dir mv ${Site_Dir}/data.js ${Site_Dir}/data.js.$(date +%F) #移动data.js wget ${Get_Url} && sed -i "s/http:\/\/qzone/https:\/\/qzone/g" ${Site_Dir}/data.js #将调用腾讯的图片改为https协议 rm -f ${Site_Dir}/data.js.* #删除之前移动的js chown www.www ${Site_Dir}/data.js #授权网站用户可以访问 fi |
基本就实现我的要求了。马马虎虎看吧。两个js我都缓存到性能魔方的cdn上面了,缓存一天时间。SourceByrd's Weblog-https://note.t4x.org/other/https-tencent-404/
效果:https://error.t4x.org/404.htmlSourceByrd's Weblog-https://note.t4x.org/other/https-tencent-404/ SourceByrd's Weblog-https://note.t4x.org/other/https-tencent-404/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!