SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    *sigh* mod_rewrite being naughty again

    Code:
    RewriteEngine On
    RewriteRule ^t([0-9]+)-([A-Za-z0-9\-]+)((p([0-9]+))?)\.html$ showthread.php?t=$1&page=$5&pp=10 [L]
    The above matches:
    t7-testing.html
    t1-some-thread-title.html

    But although it is matching t7-testing-p2.html it isn't passing the right parameter to the page= part. I know it's matching because the right page loads but the pagenumber is incorrect. I've tried with $2 all the way up to $7 and it's still not working.

    One of those headbanging moments I think

    Edit:

    Ah is the p2 part being matched from the previous rule? I didn't want to have to split this into two rules

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

    You give such good mod_rewrite, it's unusual you're asking for clarification!

    Code:
    RewriteEngine On
    RewriteRule ^t([0-9]+)-([A-Za-z0-9\-]+)((p([0-9]+))?)\.html$ 
       showthread.php?t=$1&page=$5&pp=10 [L]
    The page is $5 (fifth set of parentheses) - but where does pp=10 come from?

    Okay, I think I see the problem now! mod_rewrite doesn't know that you NEED to have p## differentiated from the second atom ("([A-Za-z0-9\-]+)") in order to get the 3rd, 4th and 5th atoms created. Yes, this is another case of the dreaded "EVERYTHING" atom. Okay, NOT quite the same but along a similar vein.

    Can you insert some character to denote the change to that "p" atom?

    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 Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I could insert the page number at the beginning I guess, I really want to use the "-" though :P I guess I'll compromise and do t#p#

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

    "~"?

    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

  5. #5
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought about that but I want to keep the characters in my URLs strictly controlled. In the end I'm going to have t#p#-thread-title.html I think Tis a shame you can't backtrack through previously matched patterns eh!


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
  •