PDA

View Full Version : Manipulate URLs (using directories instead of file.html)


lkeane
03-04-2005, 06:39 AM
Hi. Sorry to be asking such a newbie question but I am getting stuck.

I want to make my site use directories for file names.

I would like http://example.com/directory/ to load http://example.com/directory/filename.html but I do not want the name of the file to be displayed in the address bar.

I am trying to mimic an effect I noticed: http://www.happycog.com/about/ shows a .htm file but when you press 'reload' it does not show the filename.

I know this is extremely common but everyone I've asked has given a different response. I hope this is in the correct category; I don't know where it should go. Some have suggested using mod_rewrite, mod_dir, .htaccess, or some redirect. I think the easiest for me would be .htaccess because I have no experiance with any of the other apache things. Basically, I know what I want to do but I have no idea where to start and I don't know what the .htaccess code would be.

Thanks very much for any help! I appreciate any push in the right direction.

chilipie
03-04-2005, 07:52 AM
Just name the file that you want to be seen index.htm, index.html, default.htm, default.html, index.php, or whatever you server uses (ASP, JSP etc.).

You can change the default file by putting this in a .htaccess file:
DirectoryIndex file.htm default.htm index.cgi login.php
If the first file is not found, the second one is used and so on.

Please post back and tell us how you got on :) .

brothercake
03-04-2005, 02:21 PM
Or are you talking about clean URLs? Passing CGI parameters without apparently using any GET data?

There's a few different way of doing that - probably the most comprehensive article on the subject is at ALA -- http://www.alistapart.com/articles/urls/

And it's come up in a few threads here -- http://www.codingforums.com/search.php?searchid=206278

I'd definitely recommend it - I do it for all my sites now - it gives you a much cleaner addressing structure, and means you can re-order the heirarchy internally without changing page URIs

lkeane
03-04-2005, 08:44 PM
I think I'm going to try a .htaccess file with
Options Indexes FollowSymLinks MultiViews
Hopefully this should work. I dont think the DirectoryIndex one is what I want because I am trying for clean URLs. Thanks very much for your prompt replys. I'll also take a look at ala as well. Thanks again!