Mobile app version of vmapp.org
Login or Join
Steve110

: What do I put in htaccess to create a 410 error page when a URL parameter is present? I tried to create a 410 error page but realized that I actually created a 302 redirect to a 410.php

@Steve110

Posted in: #410Gone #Google #GoogleIndex #Htaccess

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:

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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Steve110

1 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme