DevChunks

Other Ways to Hide PHP Usage

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}

Share:

Leave a Reply

Your email address will not be published.

More Posts

How to use PHP Type Declarations

PHP has developed into a more strictly typed language in recent years. Type Declarations help with that and are a fairly new addition to PHP,

Iteration

If you have come to JavaScript from a background in Java or C, then you will like the variation on the for loop. It is

Context Object Manipulation

One of the key concepts of JavaScript is the keyword this, which signifies the JavaScript context object. If you write an inner function, you can access

Polymorphic Functions

It is possible to define multiple functions with the same name in JavaScript, and the last one of those that you define will be the