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.
Protect Your php.ini File
Follow these steps to hide your php.ini file:
- Log in to your Bluehost Account Manager.
- Click Hosting in the left-hand menu.

- Go to your public_html folder.
- Look for your
.htaccessfile. Right-click on the file and select Edit.
- Paste the following code at 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.
If you need further assistance, feel free to contact us via Chat or Phone:
- Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
- Phone Support -
- US: 888-401-4678
- International: +1 801-765-9400
You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.