var domain = location.hostname;
var pattern = /[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6}$/i;
// 如果是www子域名,去掉前缀
if (domain.indexOf('www.') === 0) {
domain = domain.substring(4);
}
// 使用正则表达式提取主域名
var match = domain.match(pattern);
var mainDomain = (match && match.length > 0) ? match[0] : '';
location.href = 'http://' + mainDomain + '/404.asp';发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
相关文章
JS qrcode.js当前页面生成二维码并保存jpg2020-09-16
swiper 选项卡激活指定的swiper-slide2020-04-15
Uncaught TypeError: Cannot read property 'top' of undefined错误应该如何解决2019-07-13