/// <summary> /// Creates the rule set. /// </summary> /// <param name="text">The text.</param> /// <returns></returns> public RuleSet CreateRuleSet(string text) { var ruleSet = new ApacheRuleSet("/", null); var reader = new StringReader("RewriteEngine On\n" + text); ruleSet.RefreshRules(reader); return ruleSet; }
/// <summary> /// Adds the specified relative path. /// </summary> /// <param name="relativePath">The relative path.</param> /// <param name="file">The file.</param> protected virtual void Add(string relativePath, FileInfo file) { ApacheRuleSet rule = new ApacheRuleSet(relativePath, file); Paths.Add(relativePath, rule); // start monitoring the rule set AddRuleSetMonitoring(relativePath, file.FullName); }
/// <summary> /// Runs the output rules. /// </summary> /// <param name="context">The context.</param> public virtual void RunOutputRules(HttpContextBase context) { string path = context.Request.ApplicationPath; // get the ruleset to execute ApacheRuleSet ruleSet = GetRuleSet(path); // if no rule set was found there is nothing more to do if (ruleSet == null) { return; } if (ruleSet.OutputRuleCount > 0) { context.Response.Filter = new RuleSetOutputFilter(context.Response.Filter, context, ruleSet); } }
/// <summary> /// Runs the rules. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public virtual Uri RunRules(HttpContextBase context) { var url = context.Request.Url; string path = context.Request.ApplicationPath; // get the ruleset to execute ApacheRuleSet ruleSet = GetRuleSet(path); // if no rule set was found there is nothing more to do if (ruleSet == null) { return(null); } Uri rewritenUrl = ruleSet.RunRules(context, url); return(rewritenUrl); }
/// <summary> /// Adds the specified relative path. /// </summary> /// <param name="relativePath">The relative path.</param> /// <param name="file">The file.</param> protected virtual void Add(string relativePath, FileInfo file) { ApacheRuleSet rule = new ApacheRuleSet(relativePath, file); Paths.Add(relativePath, rule); // start monitoring the rule set AddRuleSetMonitoring(relativePath, file.FullName); }