开发者

htaccess stats for specific file type

开发者 https://www.devze.com 2023-03-23 00:25 出处:网络
Ive been looking all over but couldn\'t find anything so I am here to resort to my last hope resort :)

Ive been looking all over but couldn't find anything so I am here to resort to my last hope resort :)

I am trying to create some type of page viewing sta开发者_JAVA百科tistics for only files of mine that end with swf. I was wondering if its possible that htaccess can request the URL of another php file if the file extension they are going to ends in .swf but still land on the swf page.

I know i could easily use javascript with a link onclick function but this simply wont work for direct links/reefer's.


This isn't related to .htaccess because I don't think what you want to do is possible with .htaccess (But don't quote me on that)

You could make a PHP page like this:

<?php

header('Content-type: application/x-shockwave-flash');    
$content = file_get_contents('swffile.swf');
echo $content;

// Stat tracking code here 

?>

Then you could send people directly to it and it would act like a .swf file. Since you'd be making a lot of calls to file_get_contents('swffile.swf'); which reads the file of the hard disk you'd probably also want to look into something like PHP Memcache, so you could cache the contents of you .swf file in your servers RAM and significantly speed up the request time :)


Sure you could write a simple counter script that takes as a parameter the name of the .swf file. Inside the script you would do whatever it is that you want to log it, and then return the proper header mime type for the swf, open it and return with fopen() etc. This technique is often used to secure assets that need to be accessed after a login, and should not have a direct access url available.

Of course there is overhead in processing the file through php.

If you still want to do something like this, you simply need to create a rewrite rule that finds all files ending in .swf, and redirecting them to your script along with your url parameter based on the original .swf name.

0

精彩评论

暂无评论...
验证码 换一张
取 消