Question:
How to remove a html / php / htm file extension on an www address?
jay s
2007-08-28 23:10:29 UTC
Hey people, just wondering how to 'clean up' www addresses. Prior warning, this may be a stupid question as it seems pretty simple?

I've noticed some sites have directories but no file extensions, eg:

http://www.cbs.com/latenight/lateshow/

This address is sub-directory of cbs.com, specifically, Dave Lettermans late night show website.
Is the browser looking for index.html (or something similar) by default? How is it that this does not need a file extension on the page?
How do I 'drop' the dot / extension from my site, for my main page, and my sub directories to clean it up?

Is it possibly server side as this question was answered, but only 1 user. Please do not let this change / sway / influence your answer:
http://answers.yahoo.com/question/index;_ylt=AnY73QG31Kg755W0oif6_0QjzKIX?qid=20070719192832AAeVdcP

Thank you all for your input! :-)
Three answers:
Web Maven
2007-08-29 11:37:57 UTC
It's not a stupid question. Many people don't know the full answer, because they do not operate web sites themselves and are not familiar with what can be done on a web server, based on its configuration.



A web server can be configured so when a web browser sends a request that just includes a subdirectory address, rather than a full URL including a file name, the server has a set of default file names it will look for. This is part of what's called the server configuration.



So for a given directory or subdirectory, the server may have a list like the following:



index.php

default.htm

index.htm

index.html



When someone uses their web browser and sends the URL of that directory, the server will look in the directory for those four files, in that order. If it finds a match, it delivers that file so the web browser can display the content. (If it's a .asp or .php file, it will perform certain logic first to come up with the HTML to deliver.) If it doesn't find a match, an error will result.



I fished around a little on that CBS site, and found that the full URL for the page is:

http://www.cbs.com/latenight/lateshow/index.php



so perhaps the server for that CBS site is set up something like what I described above. At least "index.php" must be in its list, and based on the current server configuration and the files present in the "latenight/lateshow/" subdir., that index.php file is what it decided to deliver for the URL you had used.



All you have to do is either follow the rules for your server, or change the configuration so the file name you are using is at the top of its list.
FMK
2007-08-28 23:26:09 UTC
Yes, it is just a sub-directory. Whenever you enter a web address without the file name, it searches for the default file of the particular sub-dir. This may differ from one server to another (IIS, PHP, .NET, etc.).



This is also why you must have a default start page for every directory everytime you create a new sub-dir (if you have ever tried yahoo geocities.. old school example). Example of default file is index.html, index.jsp, default.asp and default.aspx.



If you have experience using web editor like Frontpage, Dreamweaver or Visual Web Developer, you'll notice every time you create a new project, it will create one default web page named either index or default. So, every time you enter a sub-dir, it actually redirect back to these pages.
Riff Almighty
2007-08-29 00:22:44 UTC
It isn't removed. But the url just direct to the directory / sub-directory. And then the browser find the index or default page.



You cannot remove extension from your file because it show the type of file and how should the files opened. If you remove it, your files will become nothing but junk.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...