Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.)

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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
share|improve this answer
    
Thanks for the solution & helping me rephrase my question, worked great! –  dannyboy222 Feb 23 at 13:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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