Hi,
I have my server's apache configured to redirect every request into index.php, so that I can use urls like :
http://www.website.com/about/us
Now I need to parse the url in order to determine if each route exists and what to expect from it, so I can set a database table to save the routes and so my clients can edit their routes as they like them to be. Thing is, I'm not able to do the parsing so far.
Here's my code :
$uri = 'about/us';
$regex = '(page(/<action>))';
if ( ! preg_match($regex, $uri, $matches)) {
echo 'the route doesn\'t match';
exit();
}
It always shows up that echo message. What am I doing wrong?
edit :
The reason why I need regex is as follows. Imagine I have a url segment like :
/user/yoda
The regex here would be usefull to parse the first argument as an action or page, and the second as a key that will only allow a certain set of chars, like if I want to expect, in this case, the second paramenter only to match "_-azAZ09", something like this. In other words, the set of regex expressions would me compared to the uri in order to determine if any of them matches the uri, and determine the action to take from that on. Using the explode function would make me evaluate the uri segments later in the code, wich I'd like to avoid. If there's no match to the uri, immediatelly forward the page to a 404 one and break the operation. Don't know if I made myself clear ..