Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Return 404 on spam query URLs ( WordPress


A spammer has been blasting links to these query URLs - which are returning 302s. I'm worried about SEO-related repercussions.

<strong>I tried the following with htaccess:</strong>

RewriteEngine on
RewriteCond %{QUERY_STRING}spamword
RewriteRule (.*) /404.php? [R,L]

This sends the bad URLs to the default WordPress 404 page, but the server still returns a 302 found response. That's not quite right. Anyone know how to solve this?


Answers (2)


Dbranes answers:

You can try for example:

RewriteEngine on
RewriteCond %{QUERY_STRING} spamword1 [NC,OR]
RewriteCond %{QUERY_STRING} spamword2 [NC]
RewriteRule ^.* - [F,L]

where the F flag returns 403 forbidden and the NC flag is case insensitive.

Josh Adams comments:

Seems to have done the trick. Thanks!


zebra webdesigns answers:

Hello Josh

I need a clarification on this issue. Is the spammer posting the wrong URLs outside of your site, I mean like in forums, blogs.. or are you getting hits with wrong URL from different IP locations.

Have you installed wordfence on your site and monitored the traffic.

Josh Adams comments:

Full explanation here: