Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Problem with Regex Variables

    I'm having a problem with my PHP mod_rewrite and REGEX, but am not sure what the thing is called, so I can't Google it for help!!!

    In this PHP mod_rewrite, what the are the numbers with a $ before them called...
    #RewriteRule (.+)/(.+)/$ articles/index-subsection.php?section=$1&subsection=$2 [L]

    Next question...

    Why does it seem like things break when I get up to $10 ??

    (I have a really complicated URL, and I need a $10 thingy which my PHP will recognize!! It seems like it is being interpreted as page=$1 instead of page=$10...)



    Sincerely,


    Debbie

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    They are called placeholders.

    $10 breaks because the numbered placeholders are defined using $ followed by a single digit number.

    You might try ${10} and see if that works - that's the way some regular expression codes work - I am not sure if it works in rewrite rules.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    They are called placeholders.

    $10 breaks because the numbered placeholders are defined using $ followed by a single digit number.

    You might try ${10} and see if that works - that's the way some regular expression codes work - I am not sure if it works in rewrite rules.
    Yeah, I tried that and a whole bunch of other things, and no go.

    Rewinding for a minute...

    In my .htaccess file, should mod_rewrite get more specific or more general?

    For example do I want this...
    Code:
    #SECTION
    
    #SUBSECTION
    
    #ARTICLE

    ...or like this...
    Code:
    #ARTICLE
    
    #SUBSECTION
    
    #SECTION

    The answer to that question will probably impact - and maybe fix - the problem in my OP.

    Thanks,



    Debbie


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •