Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa HTML HTML url
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


samar
HTML url
1 Answer(s)      4 years ago
Posted in : HTML


Should I end my URLs with a slash?


Advertisement
View Answers

November 2, 2010 at 5:33 PM


The URL structure defines a hierarchy similar to a filesystem's hierarchy of subdirectories or folders. The segments of a URL are separated by slash characters ("/"). When navigating the URL hierarchy, the final segment of the URL (i.e., everything after the final slash) is similar to a file in a filesystem. The other segments of the URL are similar to the subdirectories and folders in a filesystem.

When resolving relative URLs (see the answer to the previous question), the browser's first step is to strip everything after the last slash in the URL of the current document. If the current document's URL ends with a slash, then the final segment (the "file") of the URL is null. If you remove the final slash, then the final segment of the URL is no longer null; it is whatever follows the final remaining slash in the URL. Removing the slash changes the URL; the modified URL refers to a different document and relative URLs will resolve differently.

For example, the final segment of the URL http://www.mywebsite.com/faq/html/ is empty; there is nothing after the final slash. In this document, the relative URL all.html resolves to http://www.mywebsite.com/faq/html/all.html (an existing document). If the final slash is omitted, then the final segment of the modified URL http://www.mywebsite.com/faq/html is "html". In this (nonexistent) document, the relative URL all.html would resolve to http://www.mywebsite.com/faq/all.html (another nonexistent document).

When they receive a request that is missing its final slash, web servers cannot ignore the missing slash and just send the document anyway. Doing so would break any relative URLs in the document. Normally, servers are configured to send a redirection message when they receive such a request. In response to the redirection message, the browser requests the correct URL, and then the server sends the requested document. (By the way, the browser does not and cannot correct the URL on its own; only the server can determine whether the URL is missing its final slash.)

This error-correction process means that URLs without their final slash will still work. However, this process wastes time and network resources. If you include the final slash when it is appropriate, then browsers won't need to send a second request to the server.

The exception is when you refer to a URL with just a hostname (e.g., http://www.mywebsite.com). In this case, the browser will assume that you want the main index ("/") from the server, and you do not have to include the final slash. However, many regard it as good style to include it anyway.



Related Tutorials/Questions & Answers:
HTML url
HTML url  Should I end my URLs with a slash
call json object using url and represent in html tabular form
call json object using url and represent in html tabular form  how to call json object using url from html and represent in proper format it gives Json object after that i want to arrange the keys-values in table
Advertisements
call json object using url and represent in html tabular form
call json object using url and represent in html tabular form  how to call json object using url from html and represent in proper format it gives Json object after that i want to arrange the keys-values in table
URL Encoding and URL Decoding
URL Encoding and URL Decoding  What is URL Encoding and URL Decoding ?   URL encoding is the method of replacing all the spaces and other extra characters into their corresponding Hex Characters and Decoding
Friendly URl
Friendly URl  creating a SEO friendly URL
URL problem
URL problem  Hi. I have created a webpage for my project website. in that i have used frameset to split the page. Now if i click any link in the page its navigating to the another page. but the problem is here in the url its
hide url
hide url  how i can hide url i have lot of jsp pages when i call one jsp in address another jsp page name also displayed in the address bar? url not visible to endusers please tell me any answer what i should do
HTML get Method
HTML get Method       The HTML get Method is used to submit the data of the page as part of the URL. When the form data or query is submitted, the form data is appended
Assigning URL
url to my attendancetemplate.jsp file, please help me if anyone knows, am
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
HTML
HTML  What is SPAN in HTML
html
html  How to add the calendar in html code
html
html  diffrence between html and xml
Html
Html  What is HTML? What is a Hypertext link
HTML
HTML  What is HTML? What is a Hypertext link
HTML
HTML  What is HTML? What is a Hypertext link
HTML
HTML  What is BODY in HTML document
HTML Get Radio Button
in URL. Understand with Example The Tutorial illustrates an HTML Get Radio Button... HTML Get Radio Button       HTML Get  method in HTML is used to send the data as part
html
add a header in the html page  what we can do to add a header in the html page
html
html  what we can do to add a header in the html page
html
html  what we can do to add a header in the html page
HTML
HTML  how can we give the unlimited size in the html
html
html  i want a registration page in html with good background
html
html  how to convert html page into jsp page
HTML
HTML  What is a tag? How can we use MARQUEE in HTML
HTML
HTML  How do we specify page breaks in HTML
HTML
HTML  Hi, What is the full form of HTML? Thanks   Hi, The HTML stands for HyperText Markup Language. HTML is used to create webpage for world wide web. Web pages are accessed by web browsers and then shown
html
html  sir i am new to eclipse and i am created a html program and also tomcat is running successfully in side the eclipse.but now how i deploy that html program in the eclipse
html
Adding Header in HTML  what we can do to add a header in the html page
html
html  how we can give the form actions in html after register button in the login page
 

 

 

DMCA.com