Protect your Pligg template files

Want to keep people from viewing and stealing your template files? Of course, we all do.

Here’s a simple way to keep prying eyes out of your template files and stealing your layout and functions.

In your .htaccess, add the following to the very top:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://domain.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com$      [NC]
RewriteRule .*.(tpl)$ http://www.domain.com [R,NC]

Replace all cases of domain.com with your domain name.

The last line you can specify where to send the visitor that attempts to view your .tpl file. I would leave it at your main page.

This will keep prying eyes from viewing your .tpl files.

Test it by trying to view my pligg.tpl file at http://www.faqpal.com/templates/yget/pligg.tpl

That’s it.

This is the best way I have come up with to protect your files. Got a better idea, post it below.

How do you protect your files?

If you enjoyed this post, make sure you subscribe to my RSS feed!

  • It's really need to protect your any template files and blogs. Thanks for information.
  • hiteshthakur034
    gud...its gud.....template files r a great matter of security......i needed this....
  • Good resource for protect pligg template files. Thanks for information.
  • Hi,
    I try to put in .htaccess on a site, but for me under Dreamhost, doesn't work, if I click the path with pligg.tpl I can download it from browser...

    Any idea?
    .-= Carlo´s last blog ..Dictionary.NET un interessante Traduttore instantaneo freeware =-.
  • Really very nice post!!

    This will really help us to protect our templates.
  • Nice Post. Thanks for Sharing Info For Protecting the our Template.
  • Seems this could be helpful if you have a cool and unique pligg template!

    I personally don't care if people steal my template!

    I've been asked many times to give a copy away via people sending the request using e-mail!

    I have a company doing some work for me in my career and they can easily steal any website template I was so surprised!
  • This will come in handy. (As soon as I have a cool template worth protecting:) Thanks!
blog comments powered by Disqus