Hide PHP Usage
Last Updated on: February 25, 2023
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:
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 use other .htaccess files to add to, or even override, 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:
AddType application/x-httpd-php .foo .asp .htm .html
You can now rename your file extensions and hide that you are using PHP from visitors to your site.