I'm getting sick of all of Apache's quirks, and I'm considering starting to avoid .htaccess
as much as I can in favor of writing actual, predictable code. It would be easy and straightforward to emulate things like file security and rewrites, and control precisely what is and isn't inherited between directories without having to use strange, obtuse directives. Would there be any downsides to this?
I'm talking about replacing, for example, this:
# .htaccess
RewriteCond %{HTTP_USER_AGENT} blah
RewriteRule ^(.*)$ /test$1 [R=301,L]
with something like this:
# PHP, in a header file
if(strpos($_SERVER['HTTP_USER_AGENT'], 'blah') !== false)
redirect(301, '/test' . $_SERVER['REQUEST_URI']);
To repeat the question, what would be the downsides of implementing functionality in PHP which is traditionally handled by .htaccess
?