Version 11 introduces URLRead (and others) to replace URLFetch, but I have run into a strange problem while trying to switch to the new function.

These two both work:


But whereas


successfully loads another page on the same server, this one


gives a 404 error (on my machine, running Mathematica 11.0 on Windows 7).

I had suspected that the problem was the ~ in the second URL, but replacing it by %7E does not work, and other pages with ~ can be loaded:


Other functions such as Import work fine with these addresses.

Update to summarize the answers: This seems to be a combination of a problem with the server setup, so that ~ and %7E are treated as distinct, and inconsistent URLEncode-ing behavior of URLRead.

  • $\begingroup$ I can't reproduce the error. Both URLFetch and URLRead works. (Fetch returns the page, Read returns 200-OK, clicking the green button shows the exact same redirect page source) (Mathematica 11.0 from EU/Hungary) $\endgroup$
    – Gyebro
    Commented Jan 13, 2017 at 15:01
  • $\begingroup$ 404 here. Win10 V11. $\endgroup$
    – Kuba
    Commented Jan 13, 2017 at 15:32
  • $\begingroup$ 404 here as well. MacOS 10.12.2, MMA v.11.0.1 $\endgroup$
    – Cassini
    Commented Jan 13, 2017 at 18:08

3 Answers 3


Don't know how to automatically avoid that but it seems that everything which is considered "Path" or "Query" part of the url is automatically URLEncoded.

This works on Windows:

URLRead[<|"Scheme" -> "http", "Domain" -> "www.nottingham.ac.uk/~ppzphy/"|>, "Content"]

<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<title>Your Page Title</title>
<meta http-equiv=\"REFRESH\" \
Redirecting to<br><br>
<a href=\"http://www.nottingham.ac.uk/physics/\">http://www.\

This is an incomplete answer, but it should help. I can reproduce on Windows 7. Using Fiddler it is easy to see that URLFetch issues this request:

GET /~ppzphy/ HTTP/1.1

while URLRead issues a this one:

GET /%7Eppzphy/ HTTP/1.1

Unfortunately, I didn't find a way to make URLRead work for that address.

  • $\begingroup$ Thanks, that's helpful. URLFetch["http://www.nottingham.ac.uk/%7Eppzphy/"] returns the 404 error page. $\endgroup$ Commented Jan 13, 2017 at 16:20
  • 1
    $\begingroup$ A little off-topic, but opening http://www.nottingham.ac.uk/%7Eppzphy/ in Chrome and IE works correctly, but Firefox gives the 404 page. I think this is a problem with the way the server is set up. $\endgroup$ Commented Jan 13, 2017 at 16:31

It seems like building the URL like so helps:

  <|"Path" -> "~ppzphy/"|>

This appears to avoid having URLEncode interfere.

  • 2
    $\begingroup$ BTW, I would still report this to [email protected]. At the very least its something they should be aware of. $\endgroup$
    – chuy
    Commented Jan 13, 2017 at 16:26
  • 2
    $\begingroup$ Actually one could well argument that the problem is on the server side which to my understanding should be able to answer both cases ("~" should be escaped according to RFC1738 but the newer RFC2396 classifies it as an "unreserved" character which may or may not be escaped). The real problem on the Mathematica side for me seems to be that it doesn't behave consistently on different plattforms... $\endgroup$ Commented Jan 13, 2017 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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