I have a set of rewrite rules that are supposed to process a URL that has anywhere from 1 to 5 parameters. So my URL might look like this: www.site.com/topic1/page1 or www.site.com/topic1/sub1/page1.
Here are my rules in this example:
RewriteRule ^([^/.]+)/?$ /staticpages/process-selection.php?param1=$1 [E=rwdone:yes,L]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /staticpages/process-selection.php?param1=$1¶m2=$2 [E=rwdone:yes,L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/]+)/?$ /staticpages/process-selection.php?param1=$1¶m2=$2¶m3=$3 [E=rwdone:yes,L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/]+)/([^/]+)/?$ /staticpages/process-selection.php?param1=$1¶m2=$2¶m3=$3¶m4=$4 [E=rwdone:yes,L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/]+)/([^/]+)/([^/]+)/?$ /staticpages/process-selection.php?param1=$1¶m2=$2¶m3=$3¶m4=$4¶m5=$5 [E=rwdone:yes,L]
To complicate matters, I might have a redirect 301 from an old URL to one of these new URLs. So "/topic1/page1/oldpage" might first get re-directed to "/topic1/page1/newpage".
For some reason, when the rewrite occurs, the URL that shows up in the browser has the correct URL, but with the old variables appended to the url like this: /topic1/page1/newpage?param1=page1¶m2=oldpage
I'm wondering if there's any way to avoid this situation. what the heck am I doing wrong here.