Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I'm trying to setup a proxy.pac file that may be used for IE6 clients. This is basically it:

function FindProxyForURL(url, host) {
    if (shExpMatch(host, "**")) return "DIRECT";

    return "PROXY";

This file tells the browser that any client trying to go to a host matching "**" should use a direct connection, otherwise use the proxy.

This works fine in essentially any browser, but IE6 never matches the shExpMatch no matter what I try. I've read this and disabled the cache as described here, but to no avail.

I'm positive IE6 supports the shExpMatch function, but if someone wants to correct me, I'd be glad to hear it. Incidentally, this is running on WinXP SP2.

share|improve this question
Woops, screwed up at my end, it was using the transparent proxy. – Harley Jul 2 '09 at 2:03
up vote 1 down vote accepted

Here's a slightly modified WPAD.DAT I'm using at a Customer site. It's working fine on IE6, unmodified... (because they won't give me the go-ahead to upgrade to IE8). The only modifications I put in were to obscure the Customer's domain names.

function FindProxyForURL(url, host) {

  if ( isPlainHostName(host) ) { return "DIRECT"; }

  if ( shExpMatch(url, "https:*") ) { return "DIRECT"; }

  if ( shExpMatch(url,"http://*")) { return "DIRECT"; }

  if ( isInNet(host,"", "") ) { return "DIRECT"; }

  if ( isInNet(host,"", "") ) { return "DIRECT"; }

  if ( isInNet(host,"", "") ) { return "DIRECT"; }

  return "PROXY";

The only difference that I see is that you're not matching "http:" at the beginning, but that shouldn't matter.

You're not supposed to do it, but you can put alert() statements in and IE6 will display them. You may be able to get some traction in debugging by doing that.

share|improve this answer
I also noticed he's matching against "host" vs. "url" in your example. Not sure if that matters either. – Kevin Kuphal Jul 2 '09 at 2:18
It's all good. I was watching the proxy logs and kept appearing. I found out after hours of debugging that this was because the transparent proxy was being used. Grrr. – Harley Jul 2 '09 at 2:22

I know that you've already solved it, but for others who stumble upon this there is a limitation (by design) in IE for the shExpMatch function in a PAC file in that only the * and the ? regexp wildcards are supported. An alternative is to use a regex object and call the test method on it passing in host or url as the parameter:

var regex = /**/;
    return "DIRECT";
return "PROXY";
share|improve this answer
Anyone spot the annoying bug here? Everything between /* and */ is regarded as a comment, so you get a syntax error. To do this sort of thing, you'll have to use "var regex = new RegExp('...')" – Harley Jul 3 '09 at 0:11
/**/ doesn't look like a valid regexp anyway. – Craig McQueen Sep 30 '14 at 5:47

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.