为垃圾邮件机器人制作特定的 url 响应 404 错误而不是 200

发布于 2024-12-02 12:46:19 字数 371 浏览 10 评论 0原文

当垃圾邮件机器人尝试访问我的网站时,如何使我的网站的特定网址 (index.php?act=add) 响应 404 错误而不是 200 错误?
我不是 php 程序员,所以可能可以通过 .htaccess 文件中的指令以某种方式完成?

++++

感谢您的回答,但这没有帮助(
我需要类似 .htaccess 文件中的规则:

 <Files "index.php">
 Order Deny,Allow
 Deny from all
 </Files>

但不是使用 index.php 而是使用“index.php?act=add”。

+++ 现在它工作了。谢谢你!!!

How to make my site's specific url (index.php?act=add) to response 404 error instead of 200 when spam bots try to access it ?
I am not php programmer so may be it could be done somehow with derectives in .htaccess file ?

++++

Thank you for your answers but that did not help (
I need somthing like that rule in .htaccess file:

 <Files "index.php">
 Order Deny,Allow
 Deny from all
 </Files>

But instead of index.php to use "index.php?act=add".

+++
Now its working. Thank you!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

诠释孤独 2024-12-09 12:46:19

使用 php(文件index.php)

if ($_GET['act'] == 'add') {
    if (condition to check spambot/useragent/ipaddress/cookie) {

        header("HTTP/1.0 404 Not Found");
        exit;

    } else {

        //
        //
        // your code for 'REAL' users

    }
}

using php (file index.php)

if ($_GET['act'] == 'add') {
    if (condition to check spambot/useragent/ipaddress/cookie) {

        header("HTTP/1.0 404 Not Found");
        exit;

    } else {

        //
        //
        // your code for 'REAL' users

    }
}
酷到爆炸 2024-12-09 12:46:19

您可以使用 php 标头

<?php
header("HTTP/1.0 404 Not Found");
?>

或使用 htaccess

you can use php headers

<?php
header("HTTP/1.0 404 Not Found");
?>

or use htaccess

若水般的淡然安静女子 2024-12-09 12:46:19

您可以使用 header() 函数 , 例如

if ($_GET["act"] == "add"){    
  header("HTTP/1.0 404 Not Found");
}

You can use header() function, for example

if ($_GET["act"] == "add"){    
  header("HTTP/1.0 404 Not Found");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文