3 ms·
"I never understood this obsession with having everything flow through index.php. Apache already has a method to dispatch requests to the proper controller AKA
by roel_v 15y ago
"I never understood this obsession with having everything flow through index.php. Apache already has a method to dispatch requests to the proper controller AKA file. Why rewrite it again?"
How? Is there a way to let Apache, for every request to host.domain.com execute /var/www/site/index.php ? I've seen a post somewhere claiming that years ago, and I've tried many times to get it to work or re-find that post but I never managed to do so.
- ars 15y agoYes, there is a way by rewriting (not redirect) the url. RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.php RewriteRule ^/(.*) /index.php/$1 I didn't test it, but it's probably as simple as that. But that's not what I meant. Instead of having index.php look at the url parameters and include the proper controller, just directly execute that controllers .php file. Make a file that you include in each controller that does any prep work you need and that's it, let apache execute the controller directly.
- roel_v 15y agoYes, using mod_rewrite is what I've been doing for years. My question was on the second situation - how do you let Apache execute the controller directly?