September 8, 201213 yr For some reason this is working exactly how I wanted it to on my testing machine but when I upload it to the server it doesn't work. My preg match expression is as follows... RewriteRule ^u/([a-z0-9_.]+)/?([a-z]*)/?([0-9]*)$ profile.php?username=$1&page=$2&msgNum=$3 [NC] /u/adam correctly redirects to profile.php?username=adam /u/adam/messages fails to redirect to profile.php?username=adam&page=messages /u/adam/messages/2 fails to redirect to profile.php?username=adam&page=messages&msgNum=2 I'm sure they syntax of the preg_match is correct because I am using the star which means 0 or more, and it works absolutely fine on my localhost (ZendServer CE), it just breaks when on my live server. Where should I be looking for this problem?
September 8, 201213 yr Author got that covered I think above my RewriteRules I have... Options +FollowSymLinks RewriteEngine On RewriteBase /
September 8, 201213 yr Author Try this regex instead ^u/([^/]+)(??:/([a-z]+))(?:/([0-9]+))?)?/?$ Could you explain this please??? The problem I'm having is that it works on my local host but not the live host... so there must be something different about the live host.
September 8, 201213 yr Here's the full breakdown of the regex ^u/([^/]+)(??:/([a-z]+))(?:/([0-9]+))?)?/?$ Options: case insensitive; ^ and $ match at line breaks Assert position at the beginning of a line (at beginning of the string or after a line break character) «^» Match the characters “u/” literally «u/» Match the regular expression below and capture its match into backreference number 1 «([^/]+)» Match any character that is NOT a “/” «[^/]+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» Match the regular expression below «(??:/([a-z]+))(?:/([0-9]+))?)?» Between zero and one times, as many times as possible, giving back as needed (greedy) «?» Match the regular expression below «(?:/([a-z]+))» Match the character “/” literally «/» Match the regular expression below and capture its match into backreference number 2 «([a-z]+)» Match a single character in the range between “a” and “z” «[a-z]+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» Match the regular expression below «(?:/([0-9]+))?» Between zero and one times, as many times as possible, giving back as needed (greedy) «?» Match the character “/” literally «/» Match the regular expression below and capture its match into backreference number 3 «([0-9]+)» Match a single character in the range between “0” and “9” «[0-9]+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» Match the character “/” literally «/?» Between zero and one times, as many times as possible, giving back as needed (greedy) «?» Assert position at the end of a line (at the end of the string or before a line break character) «$» Created with RegexBuddy So you're saying that that doesn't work on your server either?
September 9, 201213 yr Author Well it did work... but my other one has started working again now too, maybe the server was just messing up, it went down for 6 hours not long after... which regex would be the better one to use?
Create an account or sign in to comment