How to Hide the PHP Extension in Apache

Hiding PHP script files on your website server can prevent other users from copying the code and using it without permission on their own websites or blogs. An effective way to hide files with the PHP extension on Apache-based Web servers is to block them from public access by adding a command to the Htaccess file that controls the access settings to your website.

Instructions

    • 1

      Sign in to your website’s host server in the same way as normal, through the content management system’s control panel or with a File Transfer Protocol application.

    • 2

      Go to the website’s root folder. This folder contains the site’s index page or home page, content pages, images, multimedia files and script files.

    • 3

      Locate the “.htaccess” file in the list of files and folders in the root folder. Double-click on the file to open it in your computer’s default text editor program, which is usually Microsoft Notepad.

    • 4

      Scroll to the final line of code in the Htaccess file. Paste the following code at the end of the document:

      <IfModule mod_rewrite.c>
      Options +FollowSymLinks
      Options +Indexes
      RewriteEngine On
      RewriteCond %{SCRIPT_FILENAME} !-d
      RewriteRule ^([^\.]+)$ $1.php [NC,L]
      </IfModule>

    • 5

      Save the file to store your changes. This hides the PHP files on your servers.

Tips & Warnings

  • Following this procedure will not affect the function of the PHP files.

Related Searches:

References

Resources

Comments

Related Ads

Featured