SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mod_rewrite concepts

    I've been reading about mod_rewrite and feel almost ready to implement it on one of my sites. I do have one last question, and an answer would make me feel much better about starting with this...

    So I understand that the user will type in something friendly in the address bar (me.com/name/id), and Apache will still process it with the usual me.com?name=xxx&id=zz

    But... what happens if I forget to change one of the links in my old code, and they click on one directing to me.com?name=xxx&id=zz?

    Do you normally write 2 sets of rules, one for the user, and one for the links that already exist?

    I'd appreciate some feedback on best practices. Thanks!

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

    Old links would work just fine - unless the {REQUEST_URI} is matched by another RewriteRule (block) and another redirection made.

    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 Member
    Join Date
    Apr 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi dklynn, thanks for your answer. One other question... Is there a way I can stop the old links from looking the way they do by rewriting them in the address bar? Does it work that way? It's kind of circular, so I'm not sure it's possible.

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    vic,

    I went through that a few years ago with another member. My first answer was NO! My second answer was a rather convoluted way to "tag" the loop with a marker in the query string which would then be used to stop the loop. The third (and best by far) was to use the {IS_SUBREQ} variable ... but all that's explained in my signature's tutorial (with the sample code). You didn't bother to read that, did you?

    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


Tags for this Thread

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
  •