3 ms·
It needs to be pointed out that this kind of trick is essentially a workaround for the awful URLs caused by the "the URL is the path of the handler" scheme that
by ajross 18y ago
It needs to be pointed out that this kind of trick is essentially a workaround for the awful URLs caused by the "the URL is the path of the handler" scheme that Apache and PHP like to encourage.
It's almost always a better idea to do this another way. Note that the distinction between the "handler" part of the URL, the remaining "path-like" part and the query string is already exposed in the CGI variables (SCRIPT_NAME, PATH_INFO, and QUERY_STRING). The handlers can do this magic on their own. Doing it by placing important application code into the apache configuration for the site strikes me as very confusing.
- mseebach 18y agoAgreed. Indeed, most of the rewrites I've seen look like this: RewriteRule .* /index.php
- samataro 18y agoAre you implying that the front-controller pattern is bad?
- mseebach 18y agoNo, but mod_rewrite is not the only way of implementing it. In the mentioned case, index.php would implement a front-controller. mod_rewrite is black magic, and will fail without suggesting why, just throwing a 500 Internal Server Error. Debugging a front controller in PHP (or whatever) it much easier.