More Ways to Hide PHP Usage

Last Updated on: February 25, 2023

There are a few other methods that you can use to hide your usage of PHP from visitors to your website. Another trick is to use filenames without extensions and then tell Apache to process them as a PHP file. This can be done easily by amending your .htaccess file to include the following lines:

// Consider all extension-less files as PHP code
<Files ~ "^[^\.]+$">
    ForceType application/x-httpd-php
</Files>

The next example demonstrates how to use only a file called index for your PHP code:

// Only consider 'index' as PHP code
ForceType application/x-httpd-php

Another way to do this is to enable Multiviews, but this has many side effects that you might not want. Simply edit the .htaccess file to include the following:

Options +MultiViews

A final way to achieve the same results works on the php.ini file. This method works to stop PHP from exposing the PHP credits and adding the “X-Powered-By: PHP/x.y” header that is normally automatically added the every header response. Simply edit php.ini to include the following line:

Expose_php Off

You can also include this on a file-by-file basis by including the following code in your PHP script:

ini_set(“expose_php”, “Off”);

Get notified of new posts:


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *