I've got a group of rewrite rules that are meant to process a URL which has between 1 to five parameters. So my URL might seem like this: www.site.com/topic1/page1 or www.site.com/topic1/sub1/page1.

Listed here are my rules within this example:

RewriteRule ^([^/.]+)/?$ /staticpages/process-selection.php?param1=$1 [E=rwdone:yes,L]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /staticpages/process-selection.php?param1=$1&param2=$2 [E=rwdone:yes,L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/]+)/?$ /staticpages/process-selection.php?param1=$1&param2=$2&param3=$3 [E=rwdone:yes,L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/]+)/([^/]+)/?$ /staticpages/process-selection.php?param1=$1&param2=$2&param3=$3&param4=$4 [E=rwdone:yes,L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/]+)/([^/]+)/([^/]+)/?$ /staticpages/process-selection.php?param1=$1&param2=$2&param3=$3&param4=$4&param5=$5 [E=rwdone:yes,L]

To complicate things, I would possess a redirect 301 from a classic Hyperlink to one of these simple new Web addresses. So "/topic1/page1/oldpage" might first get re-forwarded to "/topic1/page1/newpage".

For whatever reason, once the rewrite happens, the URL that turns up within the browser has got the correct URL, however with that old variables appended towards the url such as this: /topic1/page1/newpage?param1=page1&param2=oldpage

I am wondering if there's any way of preventing this case. what is shall we be held doing wrong here.

mod_alias works later then mod_rewrite, and also the [L] flag is just valid for mod_rewrite rules, not mod_alias (i.e. individuals rules would still be relevant to the initial URL, but oddly enough apparently using the new querystring). Make it possible for mod_alias to determine the already rewritten url, make use of the [PT] flag, or else attempt to do all spinning / redirecting with mod_rewrite.