How do I configure apache to always return a 404 for URLs whose path component starts with two slashes (i.e. "//")?
We're getting such requests only from bots that don't understand scheme-relative URLs (so when they see a URL like "//somecdn.com/thingy.js" they request "http://oursite.com//somecdn.com/thingy.js"). They get a 404 response, which is fine. The problem is the 404 comes from our Django code, which dutifully then sends us an email saying someone got a 404 and their referrer was our site.
Here's our relevant apache config:
DocumentRoot /nowhere Alias /static/ /our/static/files Alias /uploads/ /our/uploaded/files <VirtualHost :*80> ServerName oursite.com WSGIScriptAlias / /our/wsgi/script </VirtualHost>
I tried inserting
RedirectMatch 404 "^//" After
DocumentRoot, but the request still ended up at the WSGI script. Changing the regex to
"^/.*$" 404'd every request (as I would expect).
"^\/\/" didn't seem to match anything.
I'm assuming I'm running afoul of some kind of multiple-
/ squashing, but I don't know how to get around it.
This Apache 2.2.22 with mod_wsgi 3.3 on Ubuntu 12.04.