Forum Moderators: phranque

Message Too Old, No Replies

Is there a way to avoid the .html extension in a domain name?

         

serengeti

6:32 pm on May 16, 2006 (gmt 0)

10+ Year Member



I want my website visitors to type in say:

http://www.example.com/example

without the .html at the end.

However, my files are html files so the above doesn't work and the users are forced to type:

http://www.example.com/example.html

in order to access that part of the site. Can I prevent this requirement of a .html extension?

On my main page (http://www.example.com), the .html extension is not required funnily enough.

Thanks.

txbakers

8:10 pm on May 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you have a few choices to do that.

One is to set a default document in each directory so that www.example.com/filename is entered, a directory called filename has a file called something which is set as the default.

The other thing to do is called URL Re-writing, which involves knowing Apache and how to use your htaccess file. It's a bit complicated, but doable.

Do a search on rewriting URLs and you'll find lots of information.

ronburk

9:41 pm on May 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On my main page (http://www.example.com), the .html extension is not required funnily enough.

Which is an instructive case to think about.

  • You type "http://www.example.com" into your client browser.
  • The browser says "Hmmm, he didn't say what resource he wanted to fetch on www.example.com" and decides that you really meant to request the resource called "/".
  • The browser calls the server for www.example.com and requests the resource called "/".
  • The server (lets assume a typical Apache config) says "hey, the resource named '/' can't really correspond to a filename under the rules this operating systems filenames, so I'll have to look at my configuration information to see what I'm supposed to do in this case."
  • The server looks in its configuration data and discovers that, if there is no more specific directive, then it should assume that any resource whose name is of the form "whatever/" should be treated internally as though the resource was for "whatever/index.html".
  • The server locates the correct "index.html" file and returns its contents as though it were actually the resource named "/".

ytswy

9:58 pm on May 16, 2006 (gmt 0)

10+ Year Member



I've never used it, but I've seen Multviews [httpd.apache.org] mentioned an an Apache option.

The effect of MultiViews is as follows: if the server receives a request for /some/dir/foo, if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements.