Can a URL Rewrite condition compare two server variables?
Solution 1:
You can use a custom rewrite provider. A provider is C# code that turns one string into another string. You can then use it in a similar way to how you'd use rewrite map:
You can pick a separator which is not valid in a url at all. (Maybe use space or something like that. I'll use |
so it's visible in this post, but you should pick some other string.)
You'll write a rule to set the value of server variable IsItMatching
. The value of the server variable will be set using your custom url rewrite provider:
{provider_name:{server_variable_1}|{server_variable_2}}
The C# code implementing the provider will then do this (pseudo-code, no error checking):
string Rewrite(string input)
{
string[] inputVariables = input.split(separator);
if (inputVariables[0] == inputVariables[1] + "/")
return "yes";
else
return "no";
}
Then you'll write one more rule to check whether the value of the IsItMatching
server variable is "yes" or "no".