for(int i =0; i < rules.Count; i++) { // get the pattern to look for, and Resolve the Url (convert ~ into the appropriate directory) string lookFor ="^"+ rules[i].LookFor +"$"; // Create a regex (note that IgnoreCase is set) Regex re =new Regex(lookFor, RegexOptions.IgnoreCase); // See if a match is found if (re.IsMatch(requestedPath)) { // match found - do any replacement needed string sendToUrl = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, re.Replace(requestedPath, rules[i].SendTo)); // log rewriting information to the Trace object app.Context.Trace.Write("ModuleRewriter", "Rewriting URL to "+ sendToUrl); // Rewrite the URL RewriterUtils.RewriteUrl(app.Context, sendToUrl); break; // exit the for loop } }
for(int i =0; i < rules.Count; i++) { // get the pattern to look for, and Resolve the Url (convert ~ into the appropriate directory) string lookFor ="^"+ rules[i].LookFor +"(.{0,})$"; // Create a regex (note that IgnoreCase is set) Regex re =new Regex(lookFor, RegexOptions.IgnoreCase); // See if a match is found if (re.IsMatch(requestedPath)) { // match found - do any replacement needed string sendToUrl = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, re.Replace(requestedPath, rules[i].SendTo)); // log rewriting information to the Trace object app.Context.Trace.Write("ModuleRewriter", "Rewriting URL to "+ sendToUrl); // Rewrite the URL RewriterUtils.RewriteUrl(app.Context, sendToUrl); break; // exit the for loop } }