Forum Moderators: phranque

Message Too Old, No Replies

Md5 and RewriteRule?

Please help !

         

justbenice

3:18 am on Jul 30, 2004 (gmt 0)

10+ Year Member



Hello. I want to protect my swf file so i will md5 my swf file name and in my html page a url of my files will look like :
md5(date)+md5(year)+md5(myflashfilename)+md5(month)+md5(hour).swf

It was done already , but i dont know how to write a RewriteRule for my .htacess that do a jod to convert that md5(date)+md5(year)+md5(myflashfilename)+md5(month)+md5(hour).swf to myflashfilename.swf .
It will be something like :
RewriteRule md5(date)+md5(year)+md5(myflashfilename)+md5(month)+md5(hour).swf$ /myflashfilename.swf [L]

but i can't do because i dont know any command of mod_rewrite
Please help
Regard.

jdMorgan

4:24 am on Jul 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



justbenice,

Welcome to WebmasterWorld [webmasterworld.com]!

The md5 hash of the filename would have to be a fixed value; mod_rewrite can match (test) pre-defined URL strings and pass requests to scripts, but cannot directly call functions, such as MD5 hash routines.

This solution sounds over-complicated, and -- begging your pardon -- ineffective. Regardless of any modification or encoding of the filename, it will be "visible" to the user's browser and therefore, directly accessible -- at least for the next hour.

I'd suggest you look into issuing a short-lived cookie to each user who visits an authorized page on your site, and then check for that cookie using mod_rewrite (or a server-side script) before serving the .swf file. Users with a correct and current cookie can be redirected to the .swf file, and those with an expired cookie or no cookie can be redirected to a "please login" file -- both would have to be be .swf files. Only the browser would have the cookie, so any attempt to request the .swf file with a download tool would fail. Hotlinking would not work, because the linking site would not be able to issue the required cookie with the correct realm.

Another alternative would be to redirect all requests for the .swf file to a server-side script to handle the authorization, if you are more comfortable with perl or php, for example.

Our forum charter [webmasterworld.com] includes links to some basic resources about mod_rewrite.

Jim

justbenice

4:34 am on Jul 30, 2004 (gmt 0)

10+ Year Member



Argg , bad luck to me . What do you think about creat a small perl script that hash that md5 string and mod_rewrite will call that string to rewrite it to a real file name?

jdMorgan

5:26 am on Jul 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Argg , bad luck to me . What do you think about...

You could create a small perl script that is included via SSI to hash the filename to an md5 string for output on your page. Then, when a hashed URL is requested by the client browser, mod_rewrite can rewrite the requested URL to another script to rewrite it to real file names.

The only requirement is that the requested hashed URL must contain enough unhashed plain-text in a fixed position to identify it as a URL that must be decoded.

Jim