Possible Duplicate:
turn URL route into funciton arguments php mvc
CMS Routing in MVC
I'm currently trying to rewrite a PHP router.
The new htaccess rewrite has the follows.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/index.php?url=$1 [L]
</IfModule>
Whilst in index.php in public
, I am getting the URL using the $url = $_GET['url'];
What I need to do is to pass $url
to the Router function:: route($url)
If a URL is passed as : /page/function/$params which would then translate as : index.php?url=page/xapp/function
, I'd need to map and route to Controller xapp
and call function($params)
.
By this time, the autoloader has already been called. I'd also need to set a default function to be called if only /page/ is called.
How would I achieve this in a router?
You should check out the code of klein.php, a small php router. I think you should figure it from that solution.
If not, check out also slim here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With