-1

I have one domain that is hotlinging my JS scripts, how to send them other script they asked with .htaccess?

I can block request with:

RewriteCond %{SERVER_NAME} ^(www\.)?exampole\.com$
RewriteRule ^ - [F]

But how to serve them another script? Lets say that they request mydomain.com/script.js and I want to send them contents of otherdomain.com/otherscript.js

Szymon Toda
  • 4,454
  • 11
  • 43
  • 62

1 Answers1

0

You need to use %{REMOTE_HOST} variable to check remote host name. Use your rule like this:

RewriteCond %{REMOTE_HOST} ^(www\.)?exampole\.com$
RewriteRule ^script\.js$ http://otherdomain.com/otherscript.js [L,R=301]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Define `not working`? If you want assistance you need to at least put some effort in detailing your problem. Which URL didn't work? How did you test it etc. – anubhava Dec 19 '13 at 20:01
  • Not working is not wroking, script that should not be hotlinked is downloaded and ran somewhere else, so solution for this case was invalid or just not working. Do you need to be explainedlike 5-years older? – Szymon Toda Dec 20 '13 at 11:34
  • Did you read my full comment? Not working can mean many things. Like looping, 404, 403, 401 also you never told which URL isn't working – anubhava Dec 20 '13 at 11:44