I am planning to post of a series of blogs on how we can use URLRewrite with and without ARR in IIS 7 and above. But before going into URLRewrite we need to understand some basics and there are some prerequisites. So in this blog we will discuss about the prerequisites below.
1) Difference between Rewrite and Redirect
2) Scope of Rewrite with ARR
3) Scope of Rewrite without ARR
4) Regular Expressions
Difference between Rewrite and Redirect:
Consider a scenario where we had an application ‘old1’ (http://bing.com/old1/) which was the old location and the content has now been moved to http://bing.com/new1/ , this can be done in two ways.
Also observe that when we use redirect client(IE for instance) knows that the url got changed and you will see a change in url in the client (browser)
Consider the same scenario where we had an application ‘old1’ (http://bing.com/old1/) which was the old location and the content has now been moved to http://bing.com/new1/ , rewrite works as below.
Over here client (for instance IE) doesn’t know that resource has changed, so the URL wont change in the client (browser).
Scope of Rewrite with ARR
With Arr URlRewrite can be used to rewrite requests to any site within the same server or any site in any backend server. To achieve this urlrewrite rules have to be created at the server level.
Scope of Rewrite without ARR
• Without ARR URLRewrite can be used to rewrite requests to any other resource within the site. We can’t rewrite requests to a different site or server.
• For eg: http://bing.com rewritten to http://bing.com/new/ or http://bing.com/a.aspx to http://bing.com/b.aspx. We cant rewrite requests from http://bing.com/* to http://Chiranth.com/
• For this url rewrite rules are created at the site level or at the application level within the site.
A regular expression (regex or regexp for short) is a special text string for describing a search pattern.
Eg: If I specify . It matches 0-9, a-z or any character
Eg: If I specify s* ; null,s,ss,sss,ssssss,etc matches the pattern
For eg: .* matches null value,start,match,a.aspx,etc.
For eg: ^s.* matches to start,snap,s, anything that starts with s.
For eg: .*s$ matches with s,paas,saas,iaas anything that ends with s.
Eg: s+ matches with s,ss,sss,etc
1. ?- matches 0 or only one occurrence of the previous character
eg: a? matches a, s? matches s
1. if your text pattern contains any of the above special characters and you want to remove the special meaning of the special characters then you can use a backslash before the special character.
Eg: \. matches . , \? matches ?, \* matches *
You will find a lot of resources in the internet for regular expressions.
I will release my next blog on how to create inbound rules, outbound rules, and rewrite maps shortly.
Those first two images (Redirect / Rewrite) appear to be the same (Redirect)?
@Tim: Sorry my bad. thanks for pointing it out. i have changed it
In case anyone doesn't know, ARR = Application Request Routing.
Quick question, when you say urlrewrite, you are referring to the IIS add-in module called "URL Rewrite", correct? The one that doesn't come with IIS 7.5 but can be easily added.
This was indeed helpful, looking forward for next update
@James:ya its the addon module that can be added to iis 7.0 and onwards
Good article & best for beginners!!