Reverse proxy subfolder - Redirects in code

Oct 17, 2010 at 8:47 PM
Edited Oct 17, 2010 at 8:47 PM

This may be really obvious, but I'm new to all this, so I'd appreciate any help I can get.  I'm using IIS 5.1.

I need to have a reverse proxy for a website I'm developing.  The main site, say resides on server1 and returns from server1.  But I want to go to server2.  I've set up this rewrite rule:

RewriteRule ^/SubFolder http://server2 [P, NC]

And that works fine.  

The relative links on the page all point correctly to the SubFolder files.

I've got forms that postback to themselves, and they work fine, for example posts to .  But then I have a Response.Redirect in the code, like this:


And it sends me back out to, which is incorrect.  I want it to stay in the SubFolder, so it will still use the reverse proxy and serve from server2.

How do I set it up so that redirects in code like this don't go back to the root?

Oct 17, 2010 at 9:07 PM

Sorry, I've got more to add.  I'm programming in ASP.Net 2.0 in C#.

I've also got a login control on  When I log in, I want it to go to

In the code of the login control it confirms the user, then does a FormsAuthentication.RedirectFromLoginPage().

The page it redirects to it should get from Web.config:

    <authentication mode="Forms">

      <forms defaultUrl="/LoggedIn/default.aspx" loginUrl="/default.aspx" timeout="20" />



But when I log in, I end up at  I can't figure out how it's coming up with this page.  Logging shows this:


[Rewrite] Input: http://server1/SubFolder/Default.aspx

[Rule 0] Input: /SubFolder/Default.aspx

[Rule 0] Rule Pattern Matched

[Rule 0] Output: http://server2/Default.aspx

[Rewrite] Proxy: http://server2/Default.aspx


[Proxy] Request: http://server2/Default.aspx

[Proxy] System.Net.HttpWebResponse

[Proxy] Received '302 Found'

[Proxy] Response: http://server1/SubFolder/Default.aspx

[Proxy] Response is being buffered

[Proxy] Responding '302 Found'



[Rewrite] Input: http://server1/LoggedIn/SubFolder/Default.aspx

[Rule 0] Input: /LoggedIn/SubFolder/Default.aspx

[Rewrite] Output: http://server1/LoggedIn/SubFolder/Default.aspx