SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,756
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,112
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    Is there any downside to creating multiple folders which each have their own "index.php" inside them?!
    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.)

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •