Yes it's certainly possible using regular expressions. Though, this isn't a PHP question, it probably belongs in "other server side languages/issues" or "general web building".
But in the meantime you can look up mod_rewrite regular expressions and take a stab yourself.