The role of URLs
??
URL is the standardized name of the Internet resource. URLs point to pieces of electronic information that tell you where they are and how they interact with them.
??
The composition of the URL
?
For example, you want to get the URL http://www.joes-hardware.com/seasonal/index-fall.html. Then the URL is divided into the following three parts.
??
The first part of the URL (http) is the URL scheme (scheme). Scenarios can tell Web clients how to access resources. In this example, theURL description is to use the HTTP protocol.
The second part of the URL (www.joes-hardware.com) refers to the location of the server. This section tells you where the Web client resource is located.
The third part of the URL (/seasonal/index-fall.html) is the resource path. The path indicates which specific local resource is requested on the server.
??
URLs provide a uniform way to name resources. Most URLs have the same: "Scenario : //server location / path" structure.
??
Syntax for URLs
??
URL provides a means of locating arbitrary resources on the Internet, but these resources are available through a variety of different scenarios (e.g. HTTP , FTP , SMTP ) to access, so URL The syntax differs depending on the scenario. However, most URLs Follow the common URL syntax, and there is a lot of overlap between the style and syntax of different URL schemes.
??
The URL syntax for most URL scenarios is based on this 9 -part common format:
??
<scheme>://<user>:<password>@
??
Almost no URL contains all of these components. The 3 most important parts of a URL are scheme(scheme), host, and path
??
Scheme
??
A scenario is actually a primary identifier that specifies how to access the specified resource, and it tells the application that is responsible for parsing the URL what protocol to use. The scenario used in our simple http URL is the http
??
Host and Port
??
To find resources on the Internet, the application needs to know which machine is loading the resources and where it can find the server that can access the target resources. both sets of information are provided by the host and port components of the URL .
??
The host component identifies the host machine that can access the resource on the Internet.
The port component identifies the network port that the server is listening on. for HTTP that uses the TCP protocol below , the default port number is .
??
User name and password
??
Many servers require that a user name and password be entered to allow the user to access the data. The FTP server is such a common example. Here are a few examples:
??
Ftp://ftp.prep.ai.mit.edu/pub/gnu
ftp://[email protected]/pub/gnu
ftp://anonymous:[email protected]/pub/gnu
Http://joe:[email protected]/sales_info.txt
??
If you provide an FTP URLto the browser but do not specify a user name and password, it will insert anonymous(anonymous user) as your user name and send a default password (Internet Explorer will send ieuser,Netscape Navigator will send Mozilla).
??
Path
??
The path component of the URL describes where the resource resides on the server. The path is usually much like a hierarchical file system path. Like what:
Http://www.joes-hardware.com:80/seasonal/index-fall.html
The path in this URL is /seasonal/index-fall.html
??
Parameters
??
In order to provide the application with the input parameters they need for proper interaction with the server, there is a parameter component in theURL .
??
This component is a list of name-value pairs in the URL , by the character ";" Separate it from the rest of the URL (and each name value pair). They provide the application with all the additional information it needs to access the resource. Like what:
??
Ftp://prep.ai.mit.edu/pub/gnu;type=d
??
In this example, there is a parameter type=d, the parameter name is type, and the value is D.
??
As mentioned earlier, the path component of theHTTP URL can be divided into several path segments. Each paragraph can have its own parameters. Like what:
??
Http://www.joes-hardware.com/hammers;sale=false/index.html;graphics=true
??
This example has two path segments,hammers and index.html. The hammers path segment has the parameter saleand its value is false. The index.html segment has a parametric graphicswith a value of true.
??
Query string
??
Suppose Joe 's Hardware store maintains a list of unsold goods in the database, and can query the list to see if the product is available, then you can query the Web database Gateway with the following URL and look at the 12731 items are in stock:
??
http://www.joes-hardware.com/inventory-check.cgi?item=12731
??
Most of this URL is similar to the other URLs we've seen. Only question marks (? The content on the right is newly emerging. This section is called the querycomponent.
??
Http://www.joes-hardware.com/inventory-check.cgi?item=12731&color=blue
??
In this example, the query component has two name / value pairs:item=12731 and color=blue. The purpose of the query is to check if the list has an entry of size large and color blue 12731.
??
Fragment
??
To refer to a fragment of a part of a resource or resource, theURL supports using the fragment (Frag) component to represent a fragment within a resource. For example, aURL can point to a specific picture or section in an HTML document.
The fragment hangs on the right-hand side of the URL , preceded by a character "#". Like what:
??
Http://www.joes-hardware.com/tools.html#drills
??
In this example, fragment drills references a section of the page /tools.html on Joe 's Hardware store Web server. This part of the name is called drills.
??
The HTTP server typically handles only the entire object, not the fragment of the object, and the client cannot deliver the fragment to the server. After the browser obtains the entire resource from the server, it displays the portion of the resource you are interested in based on the fragment.
??
??
the server handles the entire object, so URL fragments are only used by clients
??
Appendix
??
??
??
??
??
HTTP authoritative Guide chapter II URLs and resources