SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Push URLs through index.php?

    I'm re-developing my website and want to have a cleaner structure throughout.

    ideally i'd like to use a file like index.php to contain the essential includes, error reporting/handling, database connection etc, now if all pages are pushed through this then i understand i only need to declare them once and then they'll always be available to all pages on the website?

    i know i can do something like this with htaccess

    RewriteCond %{REQUEST_URI} ^
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)?$ /index.php [L]

    For the most part this works but when i have deeper urls it doesn't work properly.

    for example i might have a blog post

    ...com/blog/hello-world (blog.php?post=hello-world)

    How would i get my application to register this?

    i will also have urls like

    ...com/gallery/album/photo-album (gallery.php?album=album&photo=photo-name)

    i feel i may need to restructure my files?

    I guess in a way i want to build a mini framework with the mvc pattern and then call everything through index. what is the best way to do this?

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    Thank you, now to just find the best implementation


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
  •