'W3C Validation returning 403 Forbidden

I've got a strange problem about my website: when I try to validate HTML using W3C Validator, I get a 403 Forbidden message and I'm unable to check it. I tried another validator and it worked...
However I get another 403 error when Disqus tries to load, in the wordpress blog section of my site.

I changed file permissions but nothing has changed... But website works very well in a browser, It loads without any error!

I've also checked robots.txt and .htaccess but there is nothing which can block that website. This is my root .htaccess file:

SetEnv PHP_VER 5
SetEnv REGISTER_GLOBALS 0
DirectoryIndex index.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^apps/wishonlist/appstore(/)?$ http://clk.tradedoubler.com/click?p=24373&a=1947754&url=http://itunes.apple.com/it/app/wishonlist/id418044882?mt=8&uo=4&partnerId=2003 [R=301,L]
</IfModule>

How can I solve this problem?
Thank you so much for your help!



Solution 1:[1]

I'm not sure how you are trying to validate your website; either by manual input or programmatically (using for example PHP).

In my case I was trying to validate my website using PHP, and got a 403 Forbidden response from the validator (using get_headers). I solved it by setting a User-Agent header as follows:

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://validator.w3.org/check?uri=" . urlencode($url));
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
// Alternative: curl_setopt($curl, CURLOPT_USERAGENT, '...');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("User-Agent: Some user-agent here"));

$headers = curl_exec($curl);

That got me a nice 200 OK response

Solution 2:[2]

I know this is 10 years later, but for posterity in case it helps someone.

It seems like my IP address is blocked from accessing the page https://validator.w3.org. This happened after attempting to check a couple sites on the validator many times (I'd guess around ~25 times in the space of 3-4 hours). I have now used a VPN and was then able to get around the 403 error. I suppose it's some sort of protection against a DDoS attack in my situation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brian
Solution 2 Kimon