Im receiving some spam queries from google and i want to show and 404 header to that specific list or words if they are in the google query. I dont know if its better to use php or httaccess. Any help are welcome. Thanks in advance.
I think php may help here. I have just wrote draft code for you, let me know if you get any issue on it: <?php $bad_words = array("bad","verybad","worst"); foreach ($bad_words as $word) { if (preg_match("/$word/", $_SERVER['QUERY_STRING'])) { header("Locatin 404.php"); exit; } } ?> PHP:
this is ready code, change words inside quotes: "bad","verybad","worst" and put whole code into header of your index.php file
What trecords posted is almost correct, updated: <?php $bad_words = array("bad","verybad","worst"); foreach ($bad_words as $word) { if (preg_match("/$word/", $_SERVER['HTTP_REFERER'])) { header("Locatin 404.php"); exit; } } ?> PHP: You can also improve on it to check of the domain is indeed from google.com first.