I have an IIS 7.5 (Windows Server 2008 R2) installation that mostly works. I had to change a URL Rewrite from a 'redirect' to a 'rewrite', however, because of client software that apparently didn't want to automatically redirect to the response URL from the redirect. OK, not a huge deal. However, with the rewrite in place the user will get a 404 error if they don't use 'https'.
The rewrite/redirect was simply to repoint everything from 'http' to 'https'. There is nothing else going on with it.
(In the examples below the IP address is altered; using a test server that doesn't have a FQDN yet, so using local IP address; yes, the testing URLs above also use the same IP address.)
If the user types "https://1.1.1.1/pages/index.php", everything works great. However, if they use "http://1.1.1.1/pages/index.php" they get the 404 error message.
I have Failed Request Tracing installed and on. Not 100% sure what I am looking at there, though. I was able to pick out from the trace details that the rewrite appears to be working: in the 'Rewrite Module' section, step 34 says 'url changed'. The new URL appears to be correct: "https://1.1.1.1/pages/index.php".
But then later in the trace, after some ISAPI redirectors (a couple of Tomcat modules installed as plugins for another server process), 'module set response error status' says '404...'. The IIS log file shows that the URL is trying to be served up via port 80 for these requests, too. If you type in 'https' for the URL then the IIS logs show it using port 443 (as it should). Both of those filters end with a 'SF_STATUS_REQ_NEXT_NOTIFICATION' status.
Here is the rewrite config that I am using:
<rule name="HTTPS secondary redirect" enabled="true" stopProcessing="true"><match url="(.*)" /><conditions logicalGrouping="MatchAll" trackAllCaptures="false"><add input="{HTTP_HOST}" pattern="1.1.1.1" /><add input="{HTTPS}" pattern="^OFF$" /><add input="{REMOTE_ADDR}" pattern="127.0.0.1" negate="true" /></conditions><action type="Rewrite" url="https://{HTTP_HOST}/{R:1}" logRewrittenUrl="true" /></rule>
Any suggestions on what to look for or what is causing the problem?
Thanks,
J