Support » Fixing WordPress » site hacked, need to redirect old url's to 404

  • One of the sites I manage was hacked, probably via a plugin. I updated WP & etc… the original issue is corrected. however, in addition to being hacked, over 5000 backlinks now exist linking to this site. I am concerned about the consequences, SEO-wise.

    I want to make all of the old urls go to 404. I did not have permalinks set up prior to the hack, so all the old urls are /?xyz=zxy style. I’ve now turned on permalinks, so basically, I want ALL the /?xyz style requests to go to 404.

    I’ve tried a number of things with mod_rewrite…

    RewriteEngine On
    RewriteBase /
    RewriteRule ^\? - [R=404,L]

    But the above code does not work. The old links still link to content, they are not redirected to 404.


Viewing 1 replies (of 1 total)
  • Someone from stack overflow helped:

    RewriteRule does not work directly on query strings, you have to use RewriteCond to access them (or tricks on internal rewrites, but that’s not necessary here).


    RewriteCond %{QUERY_STRING} .+
    RewriteRule ^/?$ - [R=404,L]

    Any request to the root path with a query will end in a 404 response.

Viewing 1 replies (of 1 total)
  • The topic ‘site hacked, need to redirect old url's to 404’ is closed to new replies.