SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict pentium10's Avatar
    Join Date
    Apr 2004
    Location
    Transilvania
    Posts
    208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rewrite 2 lines rule to one line

    I always write to lines of rules to met the ending / missing or presents

    Code:
    # www.domain.com/bvb/suedtribuene	=> http://www.domain.com/?verzeichnis=b...owsuedtribuene
    RewriteRule ^bvb/suedtribuene/$ index.php?verzeichnis=bvb&method=showsuedtribuene [QSA,L]
    RewriteRule ^bvb/suedtribuene$ index.php?verzeichnis=bvb&method=showsuedtribuene [QSA,L]

    can you help me, I would like to put this in 1 line if possible
    not all my urls are ending in / sometimes works like

    www.domain.com/bvb/suedtribuene
    and sometimes
    www.domain.com/bvb/suedtribuene/
    Rype :: book, do, charge, collect,
    track time, track expenses and invoice easily on the go.
    Available on Mac, Win, iPhone, WinMobile.
    http://www.rypenow.com

  2. #2
    SitePοint Troll disgracian's Avatar
    Join Date
    Aug 2006
    Location
    Samsara
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe you can simply add a '?' after the trailing slash character to specify a 0-or-1 match. That is a standard regular expression and should work for mod_rewrite.

    Cheers,
    D.

  3. #3
    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)
    Absolutely! The ? metacharacter specifies that the preceeding character (the /) is optional, i.e., can only occur Zero or One time.

    P10, again, you might benefit from a read of the tutorial article in my signature.

    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
    SitePοint Troll disgracian's Avatar
    Join Date
    Aug 2006
    Location
    Samsara
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice looking tutorial dk. Even if p10 doesn't, I'm certainly going to give it a thorough going over. The first time I used mod_rewrite, I only half jokingly dubbed it an irregular expression engine because of the difficulty I had in getting it to do what I wanted to with relatively simple examples.

    Cheers,
    D.

  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)
    dis,

    Thanks. Please give me any (constructive, hopefully) criticism you might have. Regex is pretty simple but it's a whole new language and only a subset applies to mod_rewrite.

    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

  6. #6
    SitePoint Addict pentium10's Avatar
    Join Date
    Apr 2004
    Location
    Transilvania
    Posts
    208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I read your tutorial.
    I really loved the way you did the c/s/city selection with useing those () and the ? operator.

    Please emphasis more on examples other examples, and on how to avoide server 500 error if occurs (how to figure out, and how to correct)
    Rype :: book, do, charge, collect,
    track time, track expenses and invoice easily on the go.
    Available on Mac, Win, iPhone, WinMobile.
    http://www.rypenow.com

  7. #7
    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)
    p10,

    Thanks.

    Actually, 500 is a server error which is likely caused by an illegal directive (like putting a line with just foo in your .htaccess. The only way to troubleshoot that is to use correct syntax (or go the extreme of commenting out a line at a time).

    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
  •