SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2010
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with friendly URLs...

    Hi Everyone ... I have been beating my head against this for a long time. I have a photo gallery made from a tutorial found here on Sitepoint. Right now the gallery works by uploading the pictures, then giving it a 'file id' and 'pic-id' at the same time. Later pulling an image from database where pic-id and file-id comes equal. Here is a link http://www.rajeevthomas.com/viewgall...?cid=2&pid=424.

    How can I replace the cid, pid,? , , etc, and replace it with www.rajeevthomas.com/simple-expressions/light every time I click on an image , can these numbers and letters replaced by my image category name and image caption ( in this case it is simple-expressions/light )


    To better explain what I am trying to achieve here can be seen on this website, each time you click on the arrow to get the next image, a clean url comes up with the image caption (image name) at the end... http://www.josephkaynephoto.com/photo/shale-pastels/

    Someone suggested Appache Rewrite Mode... but does that really help in my situation? My understanding is that Appache Mode helps you to share links in a neat fashion on blogs and emails but when a person clicks on the link, it will take the person to the original link with numbers and ids ... is this correct?

    Thank for helping me...

    Rajeev

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    Hi Raj,

    A quick read of the tutorial (perhaps the example code, too) of the link in my signature will help you to understand the power of Apache's mod_rewrite module.

    As for your question, you have insufficient information contained in the new URI to redirect to your original URI (with the query string). Don't despair, though, as I've created a website for a client (http://wilderness-wally.com) where you can't see the script which serves the many pages nor can you access the primary key of each article. Very simply, the articles are accessed by the title field of the article's record with a bit of slight-of-hand by mod_rewrite (as briefly described in the tutorial).

    Of course, if you are a sysadmin, simply use a RewriteMap to map from one input to the output values you require. If not, you can create a "handler file" to do the same thing via a look-up in either a flat-file or database but that takes some nice PHP to work that out in addition to the mod_rewrite (to only redirect the "file not found" redirections to the handler script).

    Of course, this is all referenced briefly in the tutorial.

    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

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2010
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks...

    dklynn...thank you very much for helping. Your link shows exactly what I need from the links (http://wilderness-wally.com/). My link http://www.rajeevthomas.com/viewgall...?cid=2&pid=403 is bunch of gibberish now.

    I have to learn a lot to understand your reply even! I surely am going to look through your tutorial. Thanks for the link. Have a question though... is your website (http://wilderness-wally.com/) made of mode_rewrite alone or PHP and mode_rewrite combined?

  4. #4
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,148
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yathrakaaran View Post
    I surely am going to look through your tutorial. Thanks for the link.
    Also, you should consider reading the official documentation. People's personal tutorials don't always contain accurate information.
    "First make it work. Then make it better."

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    yath,

    wilderness-wally.com is a dynamic website written in PHP to fetch the articles from the database using the title field in the records (which means that I have to substitute for spaces in the URIs and back before accessing the database). Because URIs can only contain a partial set of ASCII characters (see Uniform Resource Locators - Generic Syntax for the lists of acceptable and non) which I use in the mod_rewrite code to redirect to the handler file.

    I can't see the above comment but but rest assured that all but one member has found the tutorial quite useful ... and it's the basis for the sticky posts at the top of this forum board.

    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


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
  •