mod_rewrite question

ifohdesigns
avatar
rank Enthusiast

Enthusiast


Posts: 277
Joined: 2008-02-22
Location: Providence, RI

I had a question, and this might be very simple, so please excuse my ignorance.

I am building a site for my dad's construction company, it is fairly small in size so it is just static HTML pages.

What I want to do is get rid of the "index.html" from all directories for clean URLs.

example:

http://ronrossiremodeling.com/our-work/index.html

rewritten to:

http://ronrossiremodeling.com/our-work

It should only be 2 levels deep, with a sub category for different work under "our-work".

Any help is appreciated. Thanks!

http://ifohdesigns.com - Web Design That Is Neat.
http://ifohdesigns.com/blog - Read it please.

Chris..S
Chris..S's picture
rank Moderator

Moderator


Posts: 5672
Joined: 2005-02-22

You shouldn't need to modify

You shouldn't need to modify your .htaccess for that, index.html is normally included in the default settings. If by chance its not, you can add it using the DirectoryIndex directive, see http://httpd.apache.org/docs/2.0/mod/mod_dir.html#directoryindex

ifohdesigns
ifohdesigns's picture
rank Enthusiast

Enthusiast


Posts: 277
Joined: 2008-02-22
Location: Providence, RI

Did not even think of that.

Did not even think of that. Thanks Chris

What about if instead of having the sub directories under "our-work"
I had like:

http://ronrossiremodeling.com/our-work/decks.html

and just rewrote it to not have the extension?

http://ifohdesigns.com - Web Design That Is Neat.
http://ifohdesigns.com/blog - Read it please.

Tyssen
Tyssen's picture
rank Moderator

Moderator


Posts: 6608
Joined: 2004-05-01
Location: Brisbane

Check out tip #5:

Check out tip #5: http://passwordrobot.com/blog/5-htaccess-tricks-every-webmaster-should-know/

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

Chris..S
Chris..S's picture
rank Moderator

Moderator


Posts: 5672
Joined: 2005-02-22

I wouldn't do it like tip

I wouldn't do it like tip #5. That might be ok for a handful of pages but it won't scale well. It would be possible to set up some mod_rewrite rules to add the ".html" where a .html file exists. However, its simpler to make every page an index.html. E.g. http://ronrossiremodeling.com/our-work/decks is satisfied by the page http://ronrossiremodeling.com/our-work/decks/index.html

ifohdesigns
ifohdesigns's picture
rank Enthusiast

Enthusiast


Posts: 277
Joined: 2008-02-22
Location: Providence, RI

perfect. Thanks to both of

perfect. Thanks to both of you for your input. I think that the straight "index.html" like I had originally planned, except without the htaccess. This will suffice for now, or until I get some type of CMS up and running for it (if he ever needs it).

In any case, thank you both once again.

http://ifohdesigns.com - Web Design That Is Neat.
http://ifohdesigns.com/blog - Read it please.