douou9094747 2015-07-11 16:31
浏览 27

使用php或htaccess阻止我的网站上的特定手机制作/型号

I have been getting a lot of hits from the same phone but different ISPs to my site that seem malicious. I would like to block/redirect that whole phone from being able to access my site.

The phone gets registered in my stats as: HTC One M8

How do I go about sending all hits from that make & model to a 404 page on my site using PHP or .htaccess?

  • 写回答

1条回答 默认 最新

  • dregduc63699 2015-07-11 16:40
    关注

    You can check user agent and then respond with forbidden status

    RewriteCond %{HTTP_USER_AGENT} "HTC One M8" [nocase]
    RewriteRule ^.*$ – [forbidden,last]
    

    Note that you need to add exact user agent string here and not forget to escape special characters

    But this would should be only temporary fix because you can block legitimate users from accessing your site

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思