I can't seem to figure this out:

  1. I go to some random Website.
  2. I click on a link to their portfolio page
  3. Then I check the URL bar to find something along the lines of "www.supercoolsite.com/portfolio"
  4. Now I notice there is no "index.*" file
  5. So I type in "www.supercoolsite.com/portfolio/index.html"
  6. That seems to work, but then I try index.php. That also works.
  7. Finally I try adding "ThisCan'tPossiblyWork.ItWon't"
  8. And of course that also works...

So my question is: How do they accomplish this? I can't find any information whatsoever on this issue. I've lost sleep at night! :'( Please help!

Recommended Answers

All 7 Replies

Different web hosting companies have different defaults.

Different web hosting companies have different defaults.

Okay, so it's based on how the company does it... But are they folders (the "portfolio") or files that the hosting company has striped the .* extension, or...? I still don't get it, but thanks though!

Member Avatar for GreenDay2001

Well, the root directory consists of several sub-directories.

Now suppose you goto 'http://www.xyz.com/dir'. The server you are using gives an option to set the default page(normally index.html or index.html), in each directory.

So of course portfolio is a folder, with files related to it, like index.html the default page. Index.html is the default web page. So whether you write 'http://www.xyz.com/dir' or 'http://www.xyz.com/dir/index.html', it makes no difference.

But note that although index.html is frequently used default, so it won't mean that its so in every case. Someone would have set it as 'home.htm' or anything else.

Ah... I get it now. Thanks for your help!

Although, why would "ThisCan'tWork.ItWon't" work as well? I'm guessing it's because I started in the portfolio folder and from there appended the "ThisCan'tWork.ItWon't". And since that page doesn't exist, the server simply reverts to using the default page? Could this be a simple server configuration again?

The home page name for a given server is set by the server administrator, not by you. It will be the same filename for all websites on that server. For example, geocities.com has set all of the website home pages to be "index.html", with "index.htm" also working. On the other hand, my former ISP company used "home.htm" as the default name.

You must use the server's default name as your home page filename, if you want people to be able to address your site without appending a filename to the end of the url.

Other filenames must be addressed by adding the filename to the url, e.g:

http://mysite.myserver.net/myfilename.htm

The extension of a web page MUST be .htm or .html - nothing else will open your browser to display it. You don't get to pick your own extensions. They tell the computers involved what kind of file the file is, and what application the browser should open it with.

.htm and .html are web pages.
.gif is an image
.jpg is an image
.doc is a Word document
.ItWont is not associated with any application, so it won't display. It will cause an error box to pop up.

You also have to tell the browser and server where to look for the file, if it is not in your site's top-level folder. If your page is stored in the myfolder folder, then the url would have to be:

http://mysite.myserver.net/myfolder/myfilename.htm

The server can't guess what you want it to do. You have to tell it where stuff is when you specify the url. And the file extension tells the browser what kind of stuff the file is.

Member Avatar for GreenDay2001

> The extension of a web page MUST be .htm or .html - nothing else will open your browser to display it

Perhaps it could be asp, php, aspx etc etc too.

> The extension of a web page MUST be .htm or .html - nothing else will open your browser to display it

Perhaps it could be asp, php, aspx etc etc too.

I was trying to keep it simple.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.