Is there a way to force apache to return 404 instead of 403?

RedirectMatch as in e.g. RedirectMatch 404 /\. does the trick, it prohibits access to all files or directories starting with a dot, giving a “404 Not Found” error. From the Apache manual: “The Redirect[Match] directive maps an old URL into a new one by asking the client to refetch the resource at the new location.” … Read more

Fetch a Wikipedia article with Python

You need to use the urllib2 that superseedes urllib in the python std library in order to change the user agent. Straight from the examples import urllib2 opener = urllib2.build_opener() opener.addheaders = [(‘User-agent’, ‘Mozilla/5.0’)] infile = opener.open(‘http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes’) page = infile.read()

WAMP 403 Forbidden message on Windows 7

The access to your Apache server is forbidden from addresses other than 127.0.0.1 in httpd.conf (Apache’s config file) : <Directory “c:/wamp/www/”> Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from 127.0.0.1 </Directory> The same goes for your PHPMyAdmin access, the config file is phpmyadmin.conf : <Directory “c:/wamp/apps/phpmyadmin3.4.5/”> Options Indexes FollowSymLinks MultiViews AllowOverride … Read more

Nginx 403 error: directory index of [folder] is forbidden

If you have directory indexing off, and is having this problem, it’s probably because the try_files you are using has a directory option: location / { try_files $uri $uri/ /index.html index.php; } ^ that is the issue Remove it and it should work: location / { try_files $uri /index.html index.php; } Why this happens TL;DR: … Read more

Problem HTTP error 403 in Python 3 Web Scraping

This is probably because of mod_security or some similar server security feature which blocks known spider/bot user agents (urllib uses something like python urllib/3.3.0, it’s easily detected). Try setting a known browser user agent with: from urllib.request import Request, urlopen req = Request(‘http://www.cmegroup.com/trading/products/#sortField=oi&sortAsc=false&venues=3&page=1&cleared=1&group=1’, headers={‘User-Agent’: ‘Mozilla/5.0’}) webpage = urlopen(req).read() This works for me. By the way, … Read more

tech