I have the following...
RewriteCond %{QUERY_STRING} ^PageId=9523&contentURL=10$
RewriteRule ^master_tem开发者_开发问答plate\.aspx$ community/returned-volunteers/stay-involved [R=301,L]
This works (sort of)...
Instead of www.example.com/master_template.aspx?PageId=9523&contentURL=10
I end up with www.example.com/community/returned-volunteers/stay-involved?PageId=9523&contentURL=10
The URL I want is www.example.com/community/returned-volunteers/stay-involved
Remove the QUERY_STRING from the URL.
Cleaning it up
The solution to resolve this problem is incredibly easy, so much so, you need just one character. How is it done? Ironically, the question mark is the answer. You simply have to amend your original rule by adding a question mark after the substitution so / becomes /?
rewriterule ^oldpage.php$ /? [R=301,L]
This will now rewrite oldpage to the site root and clear up the query string so you have a nice, clean rewrite. The question is the answer!
Solution is to add a question mark to the end of the rewrite rule
RewriteRule ^master_template\.aspx$ community/returned-volunteers/stay-involved? [R=301,L]
精彩评论