Only allow script to run or get request from the PHP files on the web server.
http://example.com/libs/comment.phpHere this comment.php is just an example. The libs folder contains lots of files, and the above applies to all of them. My preference is to use a .htacces method or a mode-rewrite of the folder like 666,777 etc.
I know this is not a real questions aksing just to improve security make almost sercure sites.
Well, the simplest way to do this, is define a constant in your front controller (presumably, index.php):
define('SECURE', true);
Then, test for it at the beginning of any included file:
!defined('SECURE') and exit;
This will prevent any client side access (including calling assets from the page, via JavaScript, or src attributes; everything really)
Other provisions best be made for security, as recommended in other answers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With