Other Ways to Hide PHP Usage

by jeremyjones on March 10, 2011

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:

{code type=php}
# Consider all extension-less files as PHP code
<Files ~ “^[^\.]+$”>
ForceType application/x-httpd-php
</Files>{/code}

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

{code type=php}
# Only consider ‘index’ as PHP code

ForceType application/x-httpd-php
{/code}

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:

{code type=php}
Options +MultiViews
{/code}

A final way to achieve the same results works on the php.ini file. This method works to stop PHP 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:

{code type=php}
Expose_php Off
{/code}

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

{code type=php}
<? Ini_set(“expose_php”, “Off”); ?){/code}

Leave a Comment

Previous post:

Next post: