-->

Stop swf file from being hotlinked

2019-08-30 18:51发布

问题:

I would like to know how I can stop other webmasters from hotlinking my flash application and using it on their websites.

回答1:

The easiest way to do this is to have your web server code check the HTTP Referer header and block the download if it's not from your site. If you tell us which server-side platform you've got, we may be able to give you a more specific answer than that.



回答2:

Have the flash app check the domain and if it fails to be on your domain make it redirect to your site. Let the other webmasters drive traffic to your site. :)

    import flash.net.LocalConnection;
    var lc:LocalConnection = new LocalConnection();
    switch( lc.domain ){
      case "localhost":
      case "mydomain.com"
        break;
      default:
        // do redirect here
}

I use a switch statement to detect this, because if you are testing your app and running under the local file system it will be localhost and obviously you don't want to redirect during testing