Isn't this approaching close to
mod_rewrite[
^] territory if working on non-Windows server? That could be worth looking into if so as it can save you time with having to code out the rest of your redirect.
If that isn't what you want to do (or what you are able to do) then once you have done the above 'conversion' you could do the following: If you set up a database table with at least two columns (urls to match and redirect urls) then you can perform a select query on that database table to search for "test_this_is_test" and have it return the url that you want it to redirect to which would be in the second column of the same row.
Once you have the url that you want to redirect the user to you can use a simple 'location' call pointing to the url that was pulled from the database.
Since we do not know how many url's or parsable url's you intend to be used in your system it is hard to say how easily you can do this. You would have to have a database row for each and every url that could possibly be passed to the script and where to where it should redirect.
You can use mod_rewrite to 'forward' to external sites. You would just have to write the mod_rewrite "rules" for how it should match urls. But if that doesn't work for you then perhaps my suggestion above will work okay for you after performing the previously mentioned trick to get the "test_this_is_test". Best of luck!