Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way in which I can, on OS X, effectively block against access (by browsers or potentially any process) to secure URLs by regex?

E.g. deny access to:*

but at the same time allow access to all other non-matching URLs under

I'm not looking for a solution which involves browser extensions, but that would work automatically for any browser and any fresh (extensionless) browser profile.


share|improve this question
Is this possible on any system? – Daniel Beck May 15 '11 at 18:01
@Daniel why not, with the appropriate proxy? – slhck May 15 '11 at 18:21
@slhck HTTPS requests contain the path fragment of an URL in plain text? Seriously? (I know nothing about HTTPS... I always thought everything was encrypted and the requested length could be used for side-channel attacks...) – Daniel Beck May 15 '11 at 19:31
@Daniel Oh, valid point though, I didn't realize this at first! (Should look into the appropriate standards/RFCs some time) – slhck May 15 '11 at 19:38
up vote 0 down vote accepted

You can use a proxy auto-config (PAC) file to do this if all your applications honor system proxy settings. It is a JavaScript file declaring a single function FindProxyForURL(), which provides the web browser the proxy setting for a URL. You just need to return a non-working proxy setting to prevent a connection from happening.

var normal = "DIRECT", blackhole = "PROXY";

function FindProxyForURL(url, host) {
    if(/^https:\/\/\/foo\/bar\//i.test(url)) {
        return blackhole;
    return normal;

You need to use a file URL to load the PAC file from the local hard drive. Enter this URL as the system proxy setting in the Network System Preferences panel.

This approach has been used before – see no-ads for an example of such a script that blocks many URLs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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