问题原文
原帖链接 · dannyboy222 · CC BY-SA 3.0
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_qhttp://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.)
已采纳解答
原帖链接 · Stephen Ostermiller · CC BY-SA 3.0
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 itGmeans "Gone" -- send the 410 statusLmeans "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
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
