Link to home
Start Free TrialLog in
Avatar of Rob Rudloff
Rob RudloffFlag for United States of America

asked on

https redirect in web.config gives "500" error

Hi.
Without a web.config file in the folder, when I browse to a file in that folder "http://mywebsite.net/gatewaytest.asmx", everything works.  Of course it is not secure (http).  I can also go to "https://mywebsite.net/gatewaytest.asmx" and I am successful (I get a little lock on the browser bar and the SSL cert properties can be displayed)

I want to create a standard-issue "https redirect" in a web.config file, which appears below.  

I copy the web.config file to that folder.  Then, when I browse to "http://mywebsite.net/gatewaytest.asmx", I believe it should re-write the address as "https" and bounce me to "https://mywebsite.net/gatewaytest.asmx", but I get an error:
 500 - Internal server error.
   There is a problem with the resource you are looking for, and it cannot be displayed


So, is there a problem in my web.config file, or do you think there is a problem elsewhere?
Thanks

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <remove name="Redirect to HTTP" />
                <rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                        <conditions>
                            <add input="{HTTPS}" pattern="^OFF$" />
                        </conditions>
                        <action type="Redirect" url="https://{ToLower:{HTTP_HOST}{REQUEST_URI}}" appendQueryString="false" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Open in new window

Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

try  <clear\> in place of <remove name="Redirect to HTTP" /> and see if it works.

Just to know it is conflicting with any other rules
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rob Rudloff

ASKER

Rainer -- you are awesome!
The URL rewrite module was missing on this server.  (I never even thought to look, I'm so used to it already being there.)
I installed the module and everything works great now.
Thanks