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

时间:2011-09-02 10:29:16

标签: php .htaccess http-status-code-404 spam bots

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

++++

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

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

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

+++ 现在它的工作。谢谢!!!

3 个答案:

答案 0 :(得分:1)

使用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

    }
}

答案 1 :(得分:0)

你可以使用php标题

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

或使用htaccess

答案 2 :(得分:0)

您可以使用header() function,例如

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