Hi folks:
I'm new to IIS Rewrite rules and while I've searched this and other forums, cannot find find an answer and am hoping some experienced folks will help or point me in the right direction.
As an overview, I want any request to an internal website to be intercepted by IIS, and redirected to a page with information for the user to acknowledge. Once the user acknowledges that information, I'd like them to be sent along to the page in their initial
URL request. I'd only like this to happen once per session.
The solution at which I've arrived has two, separate parts.
The first part is to create a rewrite rule that will take the incoming URL and append it as part of a query string.
Ex: https://www.incoming.com/somefile.aspx will be redirected to
https://www.incoming.com/javascript.html?redir=https://www.incoming.com/somefile.aspx
The second part--which I believe is independent of the URL rewriting--involves using Javascript that takes the incoming query, checks whether the user has a specific session cookie. If the user does not have the session cookie set, it prompts them with some
information. Once they acknowledge that information, they are sent along to the URL defined by the "redir=XXXX" name/value pair. If the user does have the session cookie set, it sends them along to the URL defined in the "redir=XXXX" name/value pair.
The Javascript part works as anticipated when I type
https://www.incoming.com/javascript.html?redir=https://www.incoming.com/somefile.aspx into the browser's address bar.
The URL rewrite is where I'm running into problems.
The latest I've come up with is:
<rewrite><rules><rule name="TEST" stopProcessing="true"><match url="(.*)" /><action type="Redirect" url="javascript.html?redir={HTTP_HOST}/{R:1}" redirectType="Found" /></rule></rules></rewrite>
I've tried various URLs in the <action> as well with no luck. Examples:
<action type="Redirect" url="https://www.incoming.com/javascript.html?redir=https://{HTTP_HOST}/{R:1}" />
<action type="Redirect" url="https://www.incoming.com/javascript.html?redir=https://www.incoming.com/{R:1}" />
Unfortunately, the rewrite parses the value as null and leaves me with:
http://www.incoming.com/javascript.html?redir=null
Anyway, looking for suggestions and any assistance is appreciated.
Thanks!