I have a "content" website that some leechers and 419 scammers love to crawl agressively which also generates costs and performance issue. :( I have no choice: I need to prevent them to access the sitemap files and index. :(

I am doing the same as Facebook: I generate a sitemap index on the fly (/sitemap.php). I whitelisted the "good" crawlers with DNS reverse lookup (PHP) and agent check (Same as Stackoverflow). To prevent whitelisted engines to make the sitemap index content public I added that header (Stackoverflow forgot it):

header('Content-type: application/xml; charset="UTF-8"', true);
header('Pragma: no-cache');
header('X-Robots-Tag: NOARCHIVE');

Question 1: Am I missing something to protect the sitemap index file?

Question 2: The problem comes from the static sitemap (.xml.gz) files generated. How can I protect them? Even if they have a "hard to guess" name, they can be found easily with a simple google query (example: "site:stackoverflow.com filetype:xml") and I have a very limited access to .htaccess.

EDIT: This is not a server config issue. Prefered language is PHP.

EDIT 2: Sorry, this is pure programmatic question, but it has been transfered from SO and I cannot close/delete it. :(

link|improve this question

57% accept rate
Can you register PHP as a handler for .gz and replicate sitemap.php functionality? – BojanG Feb 8 '10 at 18:29
feedback

migrated from stackoverflow.com Feb 8 '10 at 19:48

This question came from our site for professional and enthusiast programmers.

3 Answers

You could always use a URL for the sitemap which will not be disclosed to anyone else apart from the engines that you'll explicitly submit to.

Have a look at http://en.wikipedia.org/wiki/Sitemaps

link|improve this answer
The site maps files will be "foundable" in the search engines' cache. :( – Toto Feb 8 '10 at 17:51
1  
@Toto: I don't think they are. The example you posted holds only because someone linked to this file: meta.stackoverflow.com/questions/22308/… – cherouvim Feb 8 '10 at 17:55
feedback

You could use robots.txt to disallow the file but you could also block the IP's. A simple way to do this is to look at the HTTP referrers in your web logs and write a cron job to take those IP's (by referrer) and add them to hosts.deny for your website.

link|improve this answer
The blacklist strategy is unfortunately not possible: the scammers and leechers buy open proxies lists. :( – Toto Feb 8 '10 at 17:49
Ok, given that, do the referrers still have non-standard browser entries? If so, you can probably just change your PHP code to look through an array and see if the referrer matches a known type. Then, change your sitemap.xml to sitemap.php and use .htaccess to rename it to .xml. Then, if your sitemap is accessed by a bot, you can redirect it anywhere. Even if your .xml file is "Static" it can be renamed and read by the PHP script in a protected directory. – Mech Software Feb 8 '10 at 18:00
feedback

How about not creating sitemap.php on the fly? Instead regenerate it once a day (or whatever makes sense) and serve it up as a static file. That way, even if 10,000 crawlers a day request it—so what?

link|improve this answer
scammers will have an easy way to run scripts to contact and try to scam our users and "duplicate" the content generated by our users. – Toto Feb 8 '10 at 17:57
feedback

Your Answer

 
or
required, but never shown

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