I'm trying to use mod_rewrite to redirect URLs from a URL from an old host to a new one that uses a different URL format. The new host zero-pads the ID to six digits as follows:
Old URL:
http://www.example.com/script.cgi?page_id=123
Needs to redirect to:
http://archive.example.com/000123/
This is what I have so far:
RewriteCond %{QUERY_STRING} ^page_id=([0-9]+)$
RewriteRule ^script\.cgi http://archive.example.com/%1/? [R=301,L]
This is redirects to:
http://archive.example.com/123/
Is there any way to achieve the zero-padding with mod_rewrite or will I just have to write a handler script to redirect to the proper URL?