重定向基于用户代理

时间:2013-08-26 13:24:33

标签: javascript asp.net redirect user-agent

我想将所有不需要的请求页面重定向到网址

我每天都在2000+以上批量处理我的服务器上的example.com/garbage-value请求 该请求中没有用户代理,它显示在分析

所以我想阻止它们,我认为可能的方法是重定向它们。

网站是用asp制作的

我们可以用asp或javascript实现,还是有其他方法可以实现。

我在考虑这样的事情,但它没有效果

    //For an iPhone/iPod site:

if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) {
                document.location = "http://URL.com/iphone/";
        } 
----------------------------------------

//For an iPad site:

if ( (navigator.userAgent.indexOf('iPad') != -1)) {
                document.location = "http://URL.com/ipad/";
        }

0 个答案:

没有答案