Hi, I'l try my best to describe my problem. Consider a root directory having 10 numerical directories. In these sub directories there's another bunch of directories containing only numericals. These in turn contains an index.php. What I'd like to do is have a seperate folder with only 1 singel index.php, and when you access for example 1/4/index.php?somevar=value it should become default/index.php?cust=1&hp=4&somevar=value. Other valid ways are to access the same page would be 1/4 and 1/4/. I can't seem to get my regexp to match a ? though. I currently have this:
RewriteRule ^([0-9]+)/([0-9]+)/?[.*]?\??(.*)? default/index.php?cust=$1&hp=$2&$3 [L]
The first part matches perfectly. Then the rules states, that there might be a sequence of any characters, which might be followed by a ?, which in turn might be followed by some more characters which should be stored in $3.
The result of 1/4 becomes default/index.php?cust=1&hp=4 ( correct ).
The result of 1/4/ becomes default/index.php?cust=1&hp=4 ( correct ).
The result of 1/4/asdf=asdf becomes default/index.php?cust=1&hp=4&asdf=asdf ( correct ).
The result of 1/4/?asdf=asdf becomes default/index.php?cust1&hp=4 ( wrong, should end with &asdf=asdf ).
The result of 1/4/index.php?asdf=asdf however becomes default/index.php?cust=1&hp=4&index.php ( wrong, should end with &asdf=asdf ).
I'm not very experienced with regexp so I could really need a hint on this one! Grateful for any replies.
RewriteRule ^([0-9]+)/([0-9]+)/?[.*]?\??(.*)? default/index.php?cust=$1&hp=$2&$3 [L]
The first part matches perfectly. Then the rules states, that there might be a sequence of any characters, which might be followed by a ?, which in turn might be followed by some more characters which should be stored in $3.
The result of 1/4 becomes default/index.php?cust=1&hp=4 ( correct ).
The result of 1/4/ becomes default/index.php?cust=1&hp=4 ( correct ).
The result of 1/4/asdf=asdf becomes default/index.php?cust=1&hp=4&asdf=asdf ( correct ).
The result of 1/4/?asdf=asdf becomes default/index.php?cust1&hp=4 ( wrong, should end with &asdf=asdf ).
The result of 1/4/index.php?asdf=asdf however becomes default/index.php?cust=1&hp=4&index.php ( wrong, should end with &asdf=asdf ).
I'm not very experienced with regexp so I could really need a hint on this one! Grateful for any replies.