I maintain an asp.net 4.0 application, not MVC, based on some close source and I must implement some anti-xss in query parameters it uses. I can't access all the code and altering all the components is out of question. I can't upgrade the .net version, also. Does it make sense to try to rewrite the path to encode/escape the query strings in order to encode the query strings, to avoid some xss injection using them? Could it be done as the browsers do? Could it be done to encode when needed only, avoiding an infinite loop?
Bflag, that “instructs RewriteRule to escape non-alphanumeric characters before applying the transformation.” The example in the manual only covers the query string, but I guess this applies to any part of the URL where you insert a back reference. But I still wouldn’t hazard a guess if that would even help, resp. could be done in a way that does not destroy / falsify regular data.