Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the url /a/b/main/ID/name.ext; I'd like to grab the ID and convert it to an 8 byte hex value (16 digits). Then I would like to grab the file (assuming the id is 112233445566FF)

/main/00/11/22/33/44/55/66/FF/name.ext

In apache how do I convert the ID to 16 digit hex number and rewrite the url?

share|improve this question

1 Answer 1

I suspect that the easiest solution is to make a small script responsible for paths matching /a/b/main/ID/name.ext, and have it issue a redirect to the appropriate path.

share|improve this answer
    
How would i do that? also, the solution should work with binary files that can be resumed and audio files that can seek (say a 6mb demo m4a) –  acidzombie24 Jan 15 '11 at 21:52
    
i still have no idea how to do this. –  acidzombie24 Jan 17 '11 at 1:59
    
You would need a script, that would take the original URL, split it into components, and rewrite it with the ID expanded. This should be easy in Python, Ruby, Perl, etc., and possible with /bin/sh (but I don't have recommend that). You would place this in your server's cgi-bin directory, then use a RewriteRule to redirect access to /a/b/main/ID/name.ext to your script. Your script would then issue a 302 response with a Location: header to redirect the client to the appropriate location. –  larsks Jan 17 '11 at 19:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.