g1smd - 6:29 am on Oct 11, 2012 (gmt 0)
The basic idea is sound, but do actually pass the id value to the script.
The special rewrite needs to appear high in the htaccess file, directly after rules that block access and before rules that redirect.
You will need to add an exclusion (RewriteCond) to your non-www/www redirecting rule to NOT redirect requests for the old URLs, otherwise you will expose the redir.php script path itself as a new URL back out on to the web when an old non-www URL is requested.
If the old URL passed to the script is not valid, currently the script will return 200 OK status and a blank page. This is a disaster. The script MUST return a 404 status and you would be wise to "include" the content of your 404 error page here.
[0-9]* will allow a "blank" id to be passed to the PHP script. You should use
All of these changes are vital to overall success.
If you're interested in seeing how much traffic is being redirected, "include" the custom logger PHP code I posted a few months ago.