sharon
sharon

Reputation: 183

url without file name

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!

Upvotes: 6

Views: 12184

Answers (10)

Kyle
Kyle

Reputation: 1

Since no one has a propper answer here it is:

Most webservers look for an index file index.html. What you see as /admin is a directory or "folder". So what yo must do is make a folder with your webhost and place your files in there, make sure to rename the file to want to display when you navigate to /Whatever to index.html...

Upvotes: 0

Phong
Phong

Reputation: 6768

It depend on your http server (apache...) setting. It will for example automatically load your index.php if one exist in the directory.

EDIT:

By doing such setting, your browser will not change the address from http://site.com/ to http://site.com/index.html

Upvotes: 1

Franci Penov
Franci Penov

Reputation: 76001

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.

Upvotes: 9

Rahul Soni
Rahul Soni

Reputation: 4968

There are at least three different ways...

  1. Use Default Documents
  2. Use URL Rewriting
  3. Use MVC

Upvotes: 0

Ian Mercer
Ian Mercer

Reputation: 39277

In addition to the default file (index.html, default.htm, default.aspx, ...) most webservers allow URL rewriting which means you can map any URL onto any resource. See Apache module mod_rewrite, or Windows Application and Request Routing, or ISAPI rewrite modules.

Upvotes: 1

deceze
deceze

Reputation: 522081

Apart from the webserver doing some automagic file name guessing, it may be that there's a custom application running that handles URLs by itself. A URL is just a URL, mapping it 1:1 to a file name is just one way to do it.

Upvotes: 0

hallie
hallie

Reputation: 2845

It could be that default document is configured or the website is using MVC.

Upvotes: 0

Devin Ceartas
Devin Ceartas

Reputation: 4829

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.

Upvotes: 3

msw
msw

Reputation: 43487

The webserver re-writes the URL to a real file (usually "index.html" or "default.html") in such situations.

Upvotes: 1

JohnFx
JohnFx

Reputation: 34909

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.

Upvotes: 1

Related Questions