I’m developing a customer FrontController in my PHP application. I need to route all URL invocation through the FrontController.
Say if someone type the bellow URL on a browser,
http://www.mydomain.com/view/pages/admin/stock-maintenance.php
I need it to be route through my FontController.php and fetch all necessary data to that specific page
I’m having my FrontController.php in following directory and currently it was written to capture other requests such as form submits and hyper-link clicks in a following manner
http://www.mydomain.com/control/FrontController.php
if (isset($_REQUEST['stock-quick_search'])) {
$view = PAGES.'user/stock-search-list.php';
}
elseif (isset($_REQUEST['stock-manage_stocks'])) {
$view = PAGES.'admin/stock-maintenance.php';
}
How can I capture and route direct page URL invocations through my controller using .htaccess file?
Note: I’m new to PHP and I have very little knowledge on .htaccess file coding
Thanks in advance
The best way is using a
.htaccessfile to define URL rewriting via Apache server. The other way is to get theREQUEST_URIandexplodeit to an array, next you can get each part to check. But the first solution that I spoke is more better that this one.http://httpd.apache.org/docs/1.3/howto/htaccess.html