How to Restrict Access to .tpl Files Using .htaccess

To prevent direct access to .tpl files in your WHMCS installation, you can add a rule to your .htaccess file. This will block anyone from accessing your .tpl template files directly through the browser.

Follow these steps:

  1. Open your .htaccess file located in your WHMCS root directory.

  2. Add the following code:

<Files ~ "\.tpl$">
Order allow,deny
Deny from all
</Files>

  1. Save and close the file.

This rule will restrict access to any .tpl files, ensuring that users cannot directly view or download them through a web browser.

Important Notes:

  • Make sure to backup your .htaccess file before making any changes.
  • Ensure your server allows .htaccess overrides. If it doesn't, you may need to contact your hosting provider for assistance.
  • This method does not prevent access to .tpl files via PHP or other server-side scripts. It only restricts direct access through the browser.

  1. Set the article to be visible and assign it to an appropriate category.

  2. Save the article.

Was this answer helpful?
security tpl files .htaccess access control restrict access whmcs security website security file protection
1