When coding a web application, should all files be linked through a single index.php file.
Would doing such a thing help security, or would it make more complications later on.
How would you guys achieve this? Most (if no all) the site I have seen use this approach. Is there a reason for this?
Any help is greatly appreciated.
Doing so doesn’t such much about security.
The main advantage is that having every request go through
index.phpmakes sure that you have a single entry point into your applications’s PHP code — which means you can put your initialization / configuration code there (or call it from there) and it’ll always get executed.On the how to achieve this, you’ll need :
RewriteRuleso all requests to non-existant files are sent toindex.phpindex.phpscript (or somewhere called byindex.php, like a router), put some code to call the right controller/action.For the
RewriteRule, here’s for example what is often done with Zend Framework :