How to Protect Your php.ini File
To prevent people from viewing your php.ini file via a browser, a few lines need to be pasted into the .htaccess file. This change prevents PHP hackers from finding exploits on your site. Learn how to protect your php.ini file in a few steps and protect your site from hackers.
How to Hide Your php.ini File
Follow these steps to protect your php.ini file:
- Log in to your Bluehost Account Manager.
- Once logged in, click the Hosting tab on the left side of your Account Manager.
- If you have multiple Hosting packages on your account , click the MANAGE button on the Hosting package you want to manage.
- If you only have a single Hosting package on your account , you will be taken to the Hosting Overview page.
- Click on the FILE MANAGER button under the Quick Links section.

- Go to your public_html folder.
- Look for your .htaccess file. Right-click on the file and select Edit.

- Paste the following code into the bottom of the file and then click save:
<Files php.ini>
Order allow,deny
Deny from all
</Files>
Now, your php.ini file is protected.
Summary
Secure your php.ini file by adding specific lines of code to your .htaccess file. This will prevent any php-related breaches on your site. Go to your File Manager and add a code to deny public access to your php.ini file. Following these steps will help protect your hosting environment from hackers.