Twinaxe
Twinaxe

Reputation: 23

Load external JS only from specific referrer/domain

is it possible to load external JS files only when they are called form a specific referrer/domain?

The reason is to prevent that landing pages/websites can be copied or at least it should make it harder to do so.

Example: Let´s say there is mylandingpage.com and myjsfiles.com

On mylandingpage.com I have the code

<script src="http://myjsfiles.com/examplejavascript.js"></script>

and I want that the JS file is only loaded when it´s called from mylandingpage.com, when someone tries to load it from another domain or tries to call it directly it should show an error or nothing. Is something like that possible?

Upvotes: 2

Views: 204

Answers (1)

Vasiliy vvscode Vanchuk
Vasiliy vvscode Vanchuk

Reputation: 7169

You need Referrer Checking ( usual it used for images, google 'Prevent image hotlinking' )

Here are some links for apache web server

http://wiki.dreamhost.com/Htaccess_tricks#Prevent_image_hotlinking

http://viralpatel.net/blogs/21-very-useful-htaccess-tips-tricks/ (12. Deny access to static file data)

Upvotes: 1

Related Questions