Ask your WordPress questions! Pay money and get answers fast! (more info)

Return 404 on spam query URLs (mydomain.com/?spam) WordPress

  • SOLVED

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?

Thanks!

Answers (2)

2014-10-16

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!

2014-10-16

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: https://productforums.google.com/d/msg/webmasters/m_O1pnevHH0/uiPNub8ucEsJ