4

I tried to create a 410 error page but realized that I actually created a 302 redirect to a 410.php page. Instead I want to use a 410 error to block out an infinite number of dynamically created pages that are being indexed by Google. I have about 30k internal links that are indexed on Google thanks to a faulty internal search engine:

  • http://www.example.com/?searchkey=1_q
  • http://www.example.com/?searchkey=2ak - (etc... goes on for 30k times)

What should I write in htaccess to block anything with this "searchkey" parameter such that a 410 error page is served? (I'm not a programmer, so I would appreciate a simplified response.)

1 Answer 1

7

You could do this using the following rewrite rule in .htaccess:

RewriteEngine on 
RewriteCond %{QUERY_STRING} searchkey
RewriteRule .* - [G,L]
  • .* means that it will do this for any URL on your site (as long as the condition of having "searchkey" in the query string is met)
  • - means to leave the URL alone and not change it
  • G means "Gone" -- send the 410 status
  • L means "Last" -- so that no other rewrite rules are executed

Since you have a custom 410 gone page, you could also use the following .htaccess directive to show it instead of the default 410 gone error page:

ErrorDocument 410 /410.php
1
  • Thanks for the solution & helping me rephrase my question, worked great! Commented Feb 23, 2014 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.