I am building a website that runs all of the code trough index.php.
For example index.php?controller=something&id=01234
.
I want to use PHP to create friendly URLs, so I do this:
$request = str_replace('/root/', '', $_SERVER['REQUEST_URI']);
$params = explode('/', $request);
$controllers = array('first_c', 'second_c', 'third_c');
if (in_array($params[0], $controllers)) {
include($params[0]); // just to give an example
}
Then with a mod_rewrite rule RewriteRule ^.*$ ./index.php
I redirect everything to index.php.
I have some problems with this: Because everything is send to index.php, included .css, .js and images files. So beside the html generated by php nothing is working correctly. I'm having big troubles with this because I tried mod_rewrite for everything (instead of PHP) and I cant get it to work... please see: Apaches mod_rewrite VS. PHP routing?
Thanks.