Extension Required?

Skrying

2[H]4U
Joined
Jan 10, 2005
Messages
2,851
Running into a weird issue with the site.

When I go to test it with a browser and type in the url I must add .html to the url or the site will not go to it.

So instead of
Code:
www.examplesite.com/example
I must type
Code:
www.examplesite.com/example.html

Its not a great issue, but its rather annoying, and in the process of trying to keep URL's simple for readers, I'd like for it not to require the extention. Is this possible?

Thanks once again.
 
In the site URL

Code:
www.example.net/example

Is example a directory or an actual webpage's name (without extension)? If it is a directory (and you are using Apache) you can set the default index page (i.e. index.html) for that directory so that page gets served to people who go to
Code:
www.example.net/example


If you want something more advanced, there is mod_negotiation (again, Apache), which I think allows you to serve up pages without extensions through an option called MultiViews (through .htaccess).

http://httpd.apache.org/docs/1.3/mod/core.html#options
 
I've tried setting it as both its own web page and in its own directory.

Here's what I'm trying to do:

When you go to the site it loads up the index.html file, but when you go to say example.com/example, which is a different page it doesnt load anything unless .html is included.

If I make example a directory, will I have to have a seperate index.html inside of that in order to be loaded? Or can I still name the .html file example.html?
 
Skrying said:
When you go to the site it loads up the index.html file, but when you go to say example.com/example, which is a different page it doesnt load anything unless .html is included.

If I make example a directory, will I have to have a seperate index.html inside of that in order to be loaded? Or can I still name the .html file example.html?

For each subdirectory you can have an index.html file that loads up when you access that directory, so for example:

Code:
www.example.com/example/

The server will look for an index.html file (you can change the names of index files it looks for if you really want) to serve up.

If you wanted to serve up a webpage in the example subdirectory called example.html as the default webpage, so that...

www.example.com/example was the same as www.example.com/example/example.html

Then you can create an .htaccess file for the example subdirectory specifying that the server should look for a file called, for example, example.html

Code:
DirectoryIndex example.html

However, if what you want is what I mentioned previously, as in allowing you to serve up .html files without an extension, for example:

You have these files in your top level web directory:
index.html
blah.html
example.html

And you wanted to allow people to type in, say...

Code:
www.mysite.com/blah

and have it redirect as

Code:
www.mysite.com/blah.html

Then you would have to look at something like mod_negotiation for Apache 1.x/2.x. I have never used it, and I probably wouldn't recommend it, but you are free to do it however you want.
 
seems like mod_rewrite is in order

not sure how you could configure apache to load extensionless url's as html, but there may be a way. i'd explore that avenue before dicking around with mod_rewrite
 
Back
Top