Why can't the server know the URL's hash tag (things after "#")

The answer is simple: the browser (client) never send the hash tag to the server.

Verify it

First, I setup a simple http server on my local machine which can print request data.

Then, In the browser's address bar, I type this and press enter:

http://localhost:8888/hello?a=b&c=d#test

Finally, I got this on the server side:

GET /hello?a=b&c=d HTTP/1.1
Host: localhost:8888

As we can see above, #test is not received by the server.

Posted on 2023-01-03