A slash action quest at the end of a URL

Source: Internet
Author: User

Today suddenly curious, want to distinguish between WWW.ABC.COM/EFG and www.abc.com/efg/the two URLs of the difference. That is to analyze the URL at the end of the addition of a slash whether there is a special effect.

Find the online Introduction:

When the Web server receives a URL request that does not contain a slash at the end, such as "WWW.ABC.COM/EFG", the server searches for a file that has the name "abc" in the root directory of the Web site, and if it does not, it is treated as a directory and returns to the default home page in the ABC directory. When the Web server receives a request with a slash at the end, it is treated directly as a directory.

Similarly, according to Microsoft Official documents Internet Explorer and Connection Limits:

Another web-performance Tip:when generating hyperlinks, always include a trailing slash if possible. For instance, navigating to http://msdn.microsoft.com/ie takes one more roundtrip than http://msdn.microsoft.com/ie/. When the browser navigates-the/ie URL, the server merely sends down a 301 to The/ie/url. Both links work, and the second version is faster.

OK, according to the above material, whether we can think URL plus slash can speed up access.
Next, test it with a simple flask project:
The Flask framework binds HTTP://127.0.0.1:5000/ABC and http://127.0.0.1:5000/def/URLs by routing binding URLs and view functions.

    • IE browser, Firefox browser
      Access Http://127.0.0.1:5000/abc Normal, Access http://127.0.0.1:5000/abc/404 error, Access Http://127.0.0.1:5000/def after 301 redirect to/http 127.0.0.1:5000/def/, Access http://127.0.0.1:5000/def/Normal
       * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)127.0.0.1 - - [29/Jun/2018 22:53:16] "GET /abc HTTP/1.1" 200 -127.0.0.1 - - [29/Jun/2018 22:54:18] "GET /def HTTP/1.1" 301 -127.0.0.1 - - [29/Jun/2018 22:54:18] "GET /def/ HTTP/1.1" 200 -127.0.0.1 - - [29/Jun/2018 22:57:46] "GET /def/ HTTP/1.1" 200 -
Summarize:
    1. Web sites to be unified standards, either user access and site URL routing at the end of the URL without a slash, or not at the end of the URL slash, if the use of uniform standards at the speed of access will not be any difference.
    2. However, the user's behavior is not limited and predictable. The user may add a slash after the URL.
    3. Two technical solutions each have pros and cons: 1. The website route URL does not have the slash, the user adds the slash post to access 404, but does not have the redirection problem; 2. Site routing URL plus slash, user access to the URL regardless of the slash can be access to normal, but no slash access links do redirect, affect access speed.

<wiz_tmp_tag id= "Wiz-table-range-border" contenteditable= "false" style= "Display:none;" >

A slash action quest at the end of a URL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.