Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

url without file name

Tags:

url

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!

like image 999
sharon Avatar asked Mar 15 '10 02:03

sharon


People also ask

Can a URL be a file name?

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).

How do I get the filename in a URL?

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.

What is the default page a Web server will return if a URL without filename is requested?

Most webservers look for an index file index. html .


3 Answers

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.

like image 147
Franci Penov Avatar answered Oct 01 '22 05:10

Franci Penov


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.

like image 42
Devin Ceartas Avatar answered Oct 01 '22 06:10

Devin Ceartas


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.

like image 21
JohnFx Avatar answered Oct 01 '22 06:10

JohnFx