![]() |
How to avoid running php files using htaccess? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How to avoid running php files using htaccess? (/showthread.php?tid=19461) |
How to avoid running php files using htaccess? - El Forum - 06-08-2009 [eluser]borisoff[/eluser] To do this I write in every php file(controllers, views, etc.) Code: if (!defined('BASEPATH')) exit('No direct script access allowed'); How to avoid running php files using htaccess? - El Forum - 06-08-2009 [eluser]SpooF[/eluser] Well you can use .htaccess to restrict all access to the directory. Since php script ignore .htaccess they can be included to a script with no problem. Its not till you request them via apache .htaccess will take effect. How to avoid running php files using htaccess? - El Forum - 06-08-2009 [eluser]borisoff[/eluser] Could you write example code? How to avoid running php files using htaccess? - El Forum - 06-11-2009 [eluser]Daniel Moore[/eluser] If you are referring to having your site set up like: Code: |-webroot then you can just set up a new .htaccess file for the system and application directories. This .htaccess needs only one line: Code: deny from all If your site is set up as follows: Code: |-system it would not then be necessary to include the additional .htaccess, because your PHP files in your system and application directory would not be directly accessible in this manner. Either way would be fine. How to avoid running php files using htaccess? - El Forum - 06-18-2009 [eluser]borisoff[/eluser] Thank you ![]() |