I have the following URL structure:
http://localhost/wordpress/gallery?id=331
id specifies the id of the post.
gallery is a normal page inside which I am accessing the id of the post and fetching the attachment images using WP_Query().
I want to replace the URL of this page to:
http://localhost/wordpress/topic/place/new-delhi/gallery?id=331
in which the parameters place and new-delhi may vary in multiple other options and topic is the keyword which remains the same.
I have tried using some unfruitful .htaccess file code.
Can anyone please help?

topic,place,new-delhiand what they are (custom post type/meta data/taxonomy, etc.). – kaiser Oct 9 '12 at 12:25