That's not too hard, if I remember correctly. Just make the script executable, and throw it where you want it. The query string will be everything after the script name.
(Note: I've never actually done this. I've only read about it. If you want a referance on it, check merlyn's site. I know some of his columns involve things like that.)