Challenge 2: Friendly URL Rewrite for /article/hello-world -- Solution
Walkthrough
The match pattern ^article/([a-zA-Z0-9-]+)$ tests the incoming
relative URL against a regular expression: article/ literally,
followed by one parenthesized capture group matching one or more
letters, digits, or hyphens (enough to cover a typical slug like
hello-world), anchored at both the start (^) and end ($) so it only
matches exactly this shape of URL rather than partially matching
something longer.
{R:1} in the action refers specifically to the first parenthesized
capture group from the element above -- in this case,
whatever text matched ([a-zA-Z0-9-]+), which for a request to
/article/hello-world would be the literal string hello-world. The
action type is Rewrite rather than Redirect, since the goal here is
for the visitor's browser to keep showing the friendly URL
(/article/hello-world) while IIS internally serves the content from
article.aspx?slug=hello-world -- a Redirect would defeat the purpose
by sending the visitor's browser to the less friendly
article.aspx?slug=... URL instead.
WHY THIS WORKS AS AN ANSWER
------------------------------
This exercise checks that the reader can write a working match
pattern with a capture group, correctly reference it with {R:1}
rather than confusing it with a condition's {C:1}, and choose
Rewrite over Redirect for the specific reason that a friendly-URL
mapping needs to stay invisible to the visitor.