M HYPE SPLASH
// news

What is the purpose of "/" character at the end of URL?

By Sarah Scott

Some URLs end with /, for example .

1

1 Answer

The trailing slash denotes a directory, while non-/ denotes a file.

When a directory is specified on an HTML URL, the web-server will return the default file from the directory. This is usually index.html for the Linux Apache server, or default.htm for Microsoft's Internet Information Services (actually IIS tries in order default.htm, default.asp, index.htm, iisstart.htm). For all web-servers it is possible to specify alternatives for these defaults.

If a directory name is specified without a slash, the result is the same, but the browser will then need two requests, the first one returning only the fact that the specified item is a directory (actually the answer is a redirection to the URL with the slash appended). Therefore, specifying the trailing slash for a directory is an optimization.

This is also true for the FTP protocol, except that the FTP server will return as answer the contents of the directory.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy