SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Which form of content-displaying shall I use?

    My entire script works with a database. That means I just type http://dgdn.net/dgdn.php?id=45&cat=23. The variables control the access of the database. Cat means which table, and id, obviously, the index id of the row.

    However, I have never seen something like that again on the internet (and I have been surfing for many years now). All people use files...something like http://dgdn.net/articles/005/ Even the SitePoint site.

    Is there maybe a big disadvantage that I am not seeing? Because the big advantage of my way is that you can work on the content of the whole site just with some SQL queries...meaning if you want to turn '&' into '&' (because you forgot to consider that when you implemented the site) then it's plain easy to do that.

    Anyway, any help welcome. .)

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Search this forum for rewrite ... there are several threads on this subject. The advantage of this approach is that Apache can convert the normal URL into the real URL (with ?id=45&cat=23), but the normal is search-engine-friendly.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the neigbours (free) WIFI makes it just a little more fun

  4. #4
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Top! Thanks a bunch you two!

    Edit:
    But I don't seem to be able to run it (the first method explained in the article) on my local webserver using http://localhost/5/1

    I always get an Internal Server Error. Code is correct and db query as well...

    EDIT:
    If I have a page where I need more variables such as author name, or which word to highlight or whatever... Would I put it just like http.//site.com/category.php/5/1/Daniel/free which would highlight the word free of articles written by daniel (everything fictional) of category blabla....

    This would get kinda difficult to know how many values of $PATH_INFO you would need.. Hmm..but then again I would do it just like now with my ?cat=.... workaround. In the end just the "format" of the path-info is some other. Yay!
    Last edited by DarkAngelBGE; May 14, 2003 at 08:06.

  5. #5
    Ceci n'est pas Zoef Zoef's Avatar
    Join Date
    Nov 2002
    Location
    Malta
    Posts
    1,111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've spend quite some time a while ago trying out all these methods but in the end I setled on a method which is based on this article:
    http://alistapart.com/stories/succeed/

    I did change a few things however .

    For starters I'm redirecting 'real' files from within .htacces like so:
    PHP Code:
    <?php /*using the php tags because the code tags mess up the newlines*/ ?>
    # The directories in the rules below are excluded from the redirection rule
    RewriteRule   ^phpMyAdmin/.*$      -                  [L]
    RewriteRule   ^cms/.*$      -                  [L]

    # The files below are excluded from redirection rule
    RewriteRule   ^this_is_a_real_file.html$      -                  [L]

    # This is the rule to redirect anything else
    # (except gig, jpg, jpeg, png and css files)
    # towards index.php
    RewriteRule !\.(gif|jpe?g|png|css)$ index.php [NC,L]
    Credit were credit is due... I got some help with this from Pippo .

    And this is the little engine in the index.php file:
    PHP Code:
    <?php
    $url 
    strip_tags($_SERVER['REQUEST_URI']);    // strip html and javascript tags
    $url_array explode("/"$url);            // 'explode' it into an array
    array_shift($url_array);                     // the first one is empty anyway
    if (!end($url_array))                        // if the last one is empty (trailing slash) ...
        
    {array_pop($url_array);}                // ...get rid of it

    /* here comes your 'traffic cop code' */

    ?>
    This puts all the 'parameters' in a nice array and from thereon just use the Php you know and love.

    Is this making any sense to you?

    Rik
    English tea - Italian coffee - Maltese wine - Belgian beer - French Cognac

  6. #6
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, it makes sense. However I am not having access to htaccess somehow. I'll probably have to email my host. :/


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
  •