Reputation: 275
I'm using the following code in my ASP.NET web.config file to redirect "www" requests to my secure web site:
<rewrite>
<rules>
<clear/>
<rule name="httpsredirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{REQUEST_URI}" />
</rule>
</rules>
</rewrite>
The goal is to ensure that when someone enters
they get redirected to
.
The problem is that the redirect works just fine in sending them to the secure site, but the destination URI is missing, so they get sent to the site's root default page. Any help here? Thanks! Right now
Upvotes: 1
Views: 52
Reputation: 4515
If you check out the answer here, you'll see that they have url="https://{HTTP_HOST}{REQUEST_URI}"
as opposed to your url="https://{HTTP_HOST}/{REQUEST_URI}"
.
Upvotes: 1
Reputation: 35514
Try changing
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{REQUEST_URI}" />
To
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
Upvotes: 1