Question

Question: Normally one gets the same HTML site for the URLs http://example.com// and http://example.com/ (the first URL has two slashes in the end). I guess, I can configure my website in a way, that the served HTML differs between the two URLs. Is this always handled correctly by all clients, i.e. do all client send a get request starting with GET // HTTP/1.1 in the first line? (Or are there clients/browser who shorten the request of http://example.com// to GET / HTTP/1.1 with one slash?)

Background of my question: I want to implement a JavaScript version of my website using the hash fragement #!. In this version the whole content shall be loaded dynamically. I thought that URLs like http://example.com/foo/bar/ shall become http://example.com//#!/foo/bar/ (short URL in the end) whereby I serve under http://example.com// the JavaScript for this site version (which differs from http://example.com/). I just asked myself, whether this approach is theoretically possible or not concerning todays standards for URLs.

Was it helpful?

Solution

Here are some results, I got so far:

  • Firefox (Version 28.0): YES (sends two slashes)
  • curl (and I hope therefore also programs using libcurl): YES (sends two slashes)
  • wget: YES (sends two slashes)
  • Chromium (Version 33.0): YES (sends two slashes)

Unfortunately I have no access to more browsers now. I will update this answer. But it would be good, if you can post some more experiences in the meanwhile ;-)

Comment of @Kevin B:

Definitely suggest cross-browser/os testing this before running with it, i've had issues in the past with linking to images for example with an erroneous // instead of / in the path working in chrome but not firefox.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top