Having multiple index.php files

I just had someone recommend that instead of creating a virtual path like this…

http://local.debbie/articles/postage-meters-can-save-you-money

(Where the actual call is to: “http://local.debbie/articles.php?slug=postage-meters-can-save-you-money”)

That I consider creating an “articles” folder and place both my “article.php” template and a default “index.php” file in this new directory as well.

The advantage is that is some plays with the URL so it reads…

http://local.debbie/articles/

…then I don’t need my Mod_Rewrite to do anything, because Apache will default to “articles/index.php”

(Hope I gave enough info to make sense?!)

Anyways… Is there any downside to creating multiple folders which each have their own “index.php” inside them?!

His approach does seem simplier, but it is new to me, and conventional wisdom says I should on have ONE “index.php” in my website.

What do you think?

Debbie

That’s very common (I always do that) and there is no problem with it so far as I know. (Kevin Yank mentions it in his PHP book, too.)

DD,

(With apologies to Ralph,) that sounds like one directory/file per page. The difference between one and the other is merely (1) level of relative links and (2) number of unique directory names you can generate (without getting ridiculously long). If that’s all you want to do, build your own “tiny url” file structure and be done with it.

Regards,

DK

The big difference is the number of files you’ll need to manage. If you have a separate directory and index.php file for each product, instead of just one file, that means more files to update when you change the design of your website (for example). As far as templating and include()-ing of other files is concerned, separate files for each path is quite cumbersome.