I have seen urls like website.com/admin/ that don't actually show the "index.html" or file name after the last slash. How is this achieved?
Thank you!
However, a file name and its extension can be referred to as a URI. URI can be a locator (http://example.com) or a filename (example. txt) and the combination of both is the URL (and can still be called a URI).
The filename is the last part of the URL from the last trailing slash. For example, if the URL is http://www.example.com/dir/file.html then file. html is the file name.
Most webservers look for an index file index. html .
A URL specifies the location of a resource, but that resource does not have to actually map to a physical file on the server. It's up to the server to decide how to process the URL and how to generate the resource to return.
Most webservers started by serving all the resources from files. Thus, most of the websites out there have their pages served as files, and the URLs they recognize have the corresponding form. If the website is still using a file-based webserver, it is possible to configure it to serve particular document by default, if a file is not specified.
However, lately, there's a big movement towards decoupling of the URLs and the actual files. Usually this is achieved through default documents (where the webserver is configured to serve specific file if the URL does not specify one), URL routing (where the webserver routes the request processing based on internal rules that map the incoming URL to the actual resources), URL rewriting (where the URL request is rewritten to a different URL before processing), or a combination of both.
In particular, the MVC frameworks rely a lot on the URL routing, as the URLs exposed by a web app based on an MVC framework specify not the location of a file on the server, both actually the code execution path for the web app. For example http://example.org/user/details/12345 would not specify the 12345 file in the /user/details folder, but would specify that the method Details on the class User should be invoked with parameter 12345 to generate the response.
The web server's configuration maps the URL to a resource. Most often that's a file such as index.HTML or index.php, but there doesn't have to be a file--the web server could be configured to serve the default index (or any other URL) by returning content generated by a module or cgi. There is no requirement for a one-to-correspondance between urls and files.
There is a configuration option on most web servers that allow the administrator to set one or more files to look for if the file-name isn't found. Often, they also let you set this on a directory by directory level.
Another possibility, depending on the site, is that it uses technology to convert (aka "rewrite") the URL on the fly so the URLs entered by the user are more meaningful to the user. This technique is common for sites built using the MVC templates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With