允许URL进入网站吗? [英] Allow URLs in to website?

查看:93
本文介绍了允许URL进入网站吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在页面加载之前,我需要允许访问几个URL,其余URL将被重定向.

I have couple of URLs that I need to allow to access before page load and remaining URLs will be redirected.

expample: If user trying to access these urls they will be allowed and 
   other urls will be redirected to google.com (example)

http://mysite.com/site/Dept/IT
http://mysite.com/site/Dept/IT/ITWS
http://mysite.com/site/dept/ce
http://mysite.com/site/dept/mkt
http://mysite.com/site/teams/dgt
http://mysite.com/site/teams/mm

如何在jQuery中做到这一点?为URL创建arraylist并检查是否允许arraylist.

How can do this in jQuery? Making arraylist for URL and check against arraylist and allow them.

推荐答案

将此用于外部URL.

$(document).ready(function() {
    $('a').click(function() {
        if (!$(this).attr("href").match("^http://yoursite.com.*$"))
        {
            if (!confirm("Do you realy want to leave this site?"))
            {
                return false;
            }
        }
    });
});

如果您确实要拒绝服务器上的特殊URL,我真的建议您在服务器端进行操作.

If you realy want to reject special URL's on your server I would realy suggest you to do it serverside.

这篇关于允许URL进入网站吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆