How to remove phpinfo.php from your website
Delete the file (usually phpinfo.php or info.php) from your web folder, then check that its address now returns a 404 or 403 error. If you cannot delete it, block access to it in your server settings.
A phpinfo page is a small file, usually named phpinfo.php or info.php, that holds one line of code and prints a very long report about how PHP is set up on your server. Developers use it to test a new hosting account and often forget it afterwards. If anyone on the internet can open it, it should be removed.
What people see
Open the address and you get a long page of grey and purple tables. The top says "PHP Version" followed by a number, with the PHP logo beside it. Below are sections such as Configuration, Environment, PHP Variables and a list of loaded modules. It is not part of your website design. It is a diagnostic page that was never meant for visitors.
Why it matters
A phpinfo page does not break your site, and it is not a hack by itself. It gives away information that makes an attacker's job easier:
- Exact PHP version and modules. Attackers can match these against known weaknesses in older versions.
- Server paths. It shows the full folder path to your site and to configuration files.
- Environment variables and settings. Depending on how your server is set up, these can include database passwords, API keys or other secrets.
- Server and system details. Operating system, server software and many configuration values.
There is also a business side. Security scanners flag this page, and so do the security questionnaires that larger customers, insurers and partners sometimes send. A page like this can also get indexed by search engines, which is not a good look. It is unlikely to change your rankings directly, but it is clutter you do not want in search results.
How to check if your site has it
All of these are free:
- Type your domain followed by common names into a browser:
/phpinfo.php,/info.php,/php.php,/test.php,/i.php,/phpinfo/. If you see the PHP tables, you have the problem. - Search Google for
site:yourdomain.com phpinfoorsite:yourdomain.com "PHP Version". This shows whether the page has been indexed. - Open your hosting file manager (or FTP) and look in the website root folder, often called
public_html,www,httpdocsorpublic. Look for files with those names. Check subfolders too, including old test or staging folders. - If you use a command line, run this from a terminal to see the response code:
curl -I https://yourdomain.com/phpinfo.php
A 200 means the page is served. A 404 or 403 is what you want.
The file can have any name, so a page you cannot find by guessing may still exist. A vulnerability scan checks for this properly. In SiteMonday this is part of the week 2 OpenVAS security scan, which only runs after you prove you own the site.
How to fix it
The best fix is simply to delete the file. A page that no longer exists cannot leak anything.
- Find every copy. Use your file manager's search for
phpinfoandinfo.php. With command line access you can search file contents too:grep -rl "phpinfo" /path/to/your/site. This also catches files with unexpected names and code that callsphpinfo(). - Delete the files. Make a note of what you removed in case a developer asks. If a file is part of a plugin or application you do not recognise, check with your developer before deleting it.
- Treat secrets as exposed. If the page was public for any length of time and your environment shows passwords or keys (for example a database password or an API key), change them. Anyone who saw the page may have copied them.
- Ask Google to drop the page. If it was indexed, use the Removals tool in Google Search Console. Once the address returns 404 or 410, it falls out of search over time anyway.
If you cannot delete the file
Sometimes the file belongs to a tool you still need. Then block public access instead. On Apache, add this to the .htaccess file in the same folder (this works on Apache 2.4):
<Files "phpinfo.php">
Require all denied
</Files>
On Nginx, add a rule to the server configuration and reload Nginx:
location = /phpinfo.php { return 404; }
Step by step versions are in our Apache guide and Nginx guide. A server level option is to add phpinfo to the disable_functions setting in php.ini, which stops the function working anywhere. Your host may let you edit this under a PHP settings or PHP INI editor in the control panel. Menu names differ between hosts, and shared hosting may not allow it.
On cPanel, Plesk, WordPress and similar setups, the file lives in the same website root folder, so use the File Manager in the control panel or an FTP program. WordPress itself does not create a public phpinfo page. Its own Site Health information screen is only visible to logged in admins. If you find one, a developer, a theme or a leftover test put it there. On Laravel the web root is the public folder, so check there and also search the code for phpinfo() in routes.
How to confirm it worked
- Visit the old address in a private browser window. You should see a 404 (not found) or 403 (forbidden) page, not the PHP tables.
- Run the
curl -Icommand again and check the status code. - Try the other common names from the check list.
- Clear your site cache and CDN cache if you use one. A cached copy can keep showing the page after the file is gone.
- Search
site:yourdomain.com phpinfoagain in a few weeks.
A scanner run is the most thorough check, because it tests many names and folders you would not think to try.
How to stop it coming back
Most of these pages return because of habit, not attack. A few simple rules help:
- Never leave test files on a live site. Ask developers to remove them as part of every launch or update.
- Keep test work on a separate staging site that is password protected.
- Only upload files through a deployment process that you control, so stray files get noticed.
- Do not store secrets where they can be shown by a diagnostic page. Keep them out of the web root.
- Re-scan after big changes such as a migration, new host or new developer. Related leftovers like an exposed .env file often appear in the same places.
If you use SiteMonday, finding this problem is the first half. It lists what it found in a ranked fix list, and the deleting is done by you or your developer.
Step by step for your platform
- phpinfo page publicly accessible on Apache
- phpinfo page publicly accessible on Nginx
- phpinfo page publicly accessible on cPanel
- phpinfo page publicly accessible on WordPress
- phpinfo page publicly accessible on Plesk
- phpinfo page publicly accessible on IIS
- phpinfo page publicly accessible on Laravel
Questions
Is it safe to just delete phpinfo.php?
Yes, in almost every case. The file only prints server information and nothing on your site depends on it, unless a developer wired it into a tool, so ask them if you are unsure.
Will removing phpinfo.php hurt my SEO?
No. It is not a page visitors or search engines need, and a 404 for it is normal. Removing it can actually clean up any indexed copy in search results.
Do I need to change my passwords after finding a phpinfo page?
If the page showed passwords or API keys in its environment section, yes, change them. If it showed none, the risk is lower, but changing secrets is still sensible if it was public for a long time.
The file keeps coming back after I delete it. Why?
Something is recreating it: a deployment script, a backup restore, a plugin, or someone who has access to your site. Check your deployment process and file upload access, and have a developer look for unwanted access if it keeps returning.
Can I hide phpinfo instead of deleting it?
You can block it with an Apache or Nginx rule, or turn off the function with `disable_functions` in `php.ini`. Deleting the file is simpler and safer, since a blocked file can be exposed again by a configuration change.
What is the difference between phpinfo.php and info.php?
Nothing, they are just names people choose. Any file that calls the `phpinfo()` function creates the same page, so search for the function and not only the file names.