0

I am exposed to HTTP for several days, and today I encounter a problem as regards baidu search engine. Details as follow:

As I open http://www.baidu.com/ with desktop browser and type in some keyword, then press ENTER, the browser url displayed is something like http://www.baidu.com/#wd=stackoverflow&ie=utf-8 with stackoverflow as the search keyword.

Please notice the anchor #wd here. It seems pretty strange to me though, eg. as to Google for example, it would be something like https://www.google.com/search?q=stackoverflow without any anchor.

I use Fiddler (http://www.telerik.com/fiddler) to inspect the HTTP packet interaction, and curiously found something like GET /s?ie=utf-8&wd=linux HTTP/1.1 after several HTTP packet interaction.

In the whole process, the server only responses HTTP/1.1 200 OK and there is no stuff like HTTP/1.1 302 Moved Temporarily etc.

So how could it finally redirect to GET /s?ie=utf-8&wd=linux HTTP/1.1, what does the browser do to the anchor #wd?

Thanks in advance.

1
  • After a conversation with a front-end guy, he told me it's something about Async Javascript ... Commented Mar 11, 2014 at 13:49

1 Answer 1

1

The component of the url after the # sign is called the URL Fragment. It is not directly sent to the server as a part of the HTTP request (which is why you don't see it in Fiddler); it is only accessible by the JavaScript running on the page.

Some sites use URL fragments when they've used AJAX techniques to populate a page; see http://blogs.msdn.com/b/ieinternals/archive/2011/05/17/url-fragments-and-redirects-anchor-hash-missing.aspx for some discussion.

Sign up to request clarification or add additional context in comments.

2 Comments

Much thanks for your info! Why the Baidu search engine defaultly use #wd=keywordinstead of s?q=keyword just like what Google do? Is there any benefit from doing so?
Google also can use the https://www.google.com/#q=yourqueryhere syntax, depending on what settings you have configured. The value in using # instead of ? is that the fragment syntax allows all processing to happen using AJAX on the client, while any change to the value after the ? requires a browser navigation. The benefit of using a query string (?) is that it works without JavaScript enabled.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.