DevChunks

If you are the web developer for a site, then you might not want visitors to know that you are using PHP for your scripting. One simple way around this is to use a different extension for the PHP files instead of the default .php. You can use any extension that you want including:

  • .htm
  • .html
  • .foo
  • .myscriptstuff

You can then create, or edit, a .htaccess file in that folder to allow access to the file extension that you have specified.  If you are not familiar with the .htaccess file, then you might be interested to learn that they are invisible files that contain server directives. These files are similar to the global settings in a httpd.conf or php.ini file, but apply only to that directory and folders inside in.

You can use .htaccess files to configure granular server directives where each folder inherits from its parent and using other .htaccess files to add to, or even over-ride, the inherited properties. Be careful though, one small change to the top-level file can change your entire site!

To allow the use of these files, go to the httpd.conf file and make the following amendments before restarting Apache to commit the change:

Change                     AllowOverride None
To                                AllowOverride All

Once your site can use .htaccess files, then you need to make a small amendment to the file to show which file extensions the site can display. Just add the following line to the file that is in the same folder as your PHP code to allow it to use files with a .foo extension:

{code type=php}
AddType application/x-httpd-php .foo .asp .htm .html
{/code}

You can now rename your file extensions and hide that you are using PHP from visitors to your site.

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