前两天要上个紧急项目,用的是阿里云服务器,域名不备案没法访问,只能做域名转发。买了台便宜的香港主机,绑定域名设置解析,然后通过JavaScript
实现访问未备案域名跳转至业务域名
。完整代码如下
<!DOCTYPE html> <html> <head> <title>跳转中...</title> <meta charset="UTF-8"> </head> <body> <script type="text/javascript"> if (window.location.href.indexOf("未备案域名") > -1) { location.href = "转发的域名"; } else if (window.location.href.indexOf("未备案域名2") > -1) { location.href = "转发的域名"; } else if (window.location.href.indexOf("未备案域名3") > -1) { location.href = "转发的域名"; } </script> </body> </html>
本文作者为吾名,转载请注明。