How can config.php be protected to prevent unauthorized access to sensitive information in a PHP application?
To protect config.php from unauthorized access, it should be placed outside the web root directory. This way, it cannot be accessed directly through a URL. Additionally, you can use file permissions to restrict access to the file and encrypt sensitive information stored in the config file.
<?php
// Place config.php outside the web root directory
// Restrict access to the file using file permissions
// Encrypt sensitive information stored in the config file
// Example code to include config.php
require_once('/path/to/config.php');
Related questions
-
fsockopen website reachability PHP
-
PHP error handling data extraction
-
content management systems frameworks web portals