I have some PHP sites that embeds SWF files. These SWF files are now linked to by some other guys. And I don't want them to simply open the SWF, I want them to force being redirect to the page where the flash is embed.

  1. www.example.com/1
  2. www.example.com/2
  3. www.example.com/3

Flash: www.example.com/flash/flash_NUMBER.swf

So for www.example.com/1 > www.example.com/flash/flash_1.swf

**I now want to redirect the user who types www.example.com/flash/flash_1.swf into his URL to be redirect to www.example.com/1.

The Problem I have that the flash needs to be still accessible via www.example.com/1 <-- I don't get that working (the Flash is embed into that page).

The tool I would like to use for this is the .htaccess & RewriteRule. I hope someone can help me out.

1 Answer 1


Well you can't make the users browser redirect while they are on the other site. You can however make it send a different file instead of the SWF they are hotlinking to.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(swf)$ http://yourdomain.com/blocked.swf [NC,R,L]

Just change yourdomain.com with your domain and blocked.swf to whatever file you want them to see instead.

In the future you can code something in your flash files that looks for the host name and redirects them I'm sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.