View of php.ini code in your browserBy default the php.ini file is stored in the public_html folder on your server. When you visit your domain and add /php.ini at the end of it like the following:

http://your-domaincom/php.ini

You will see the contents of your PHP configuration available over the internet. See the image to the right. To secure your php.ini settings so they are not publicly viewable, you can restrict access to the php.ini and other file types with the following code in your .htaccess.

<filesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
 Order Allow,Deny
 Deny from all
</filesMatch>

The parameters "htaccess|htpasswd|ini|phps|fla|psd|log|sh" in the code will restrict anyone trying to see the following file types.

  • .htaccess
  • .htpasswd
  • .ini
  • .phps
  • .fla
  • .psd
  • .log
  • .sh

You can add more file types to the restriction by separating each file type in the code with a | and adding the file extension without the ( . ). The following steps explain how to restrict files access to your pip.ini and other secure files types.

Restricting access to the php.ini and other file types

  1. Login into your cPanel.
  2. Go to the File Manager. Select your public_html web root and click Go.
  3. code to restrict php.ini access in htaccessFind your .htaccess file and edit it with a code editor. Place the following code in your .htaccess.
    <filesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
     Order Allow,Deny
     Deny from all
    </filesMatch>

    Save the changes.


    php.ini not viewable onlineNow when you visit your php.ini in your browser you will get a "Not found" error.

For more information on our .htaccess tutorials, please see our .htaccess file reference list.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve our Support Center:
Email Address
Optional, but our team may contact you for more information.
Like this Article?

Post a Comment

Name:
Email Address:
Comment:
Are you a bot?
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!