Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)


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

share|improve this question

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


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.