Other Ways to Hide PHP Usage

by jeremyjones on March 10, 2011

  • Share
  • CevherShare
  • Share

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 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 follow code in your PHP script:

<? Ini_set(“expose_php”, “Off”); ?)

Leave a Comment

Previous post:

Next post: