Answered by:
Redirection happening when it shouldn't be

Question
-
User939327180 posted
I'm running IIS 10 on Windows Server 2019 on Amazon Web Services and something odd is going on. Note that I've prevented access to the server from the internet at the moment for security reasons, so access to IIS websites is internal only.
I have set the IIS binding to the network adapter.
I installed XenForo at C:\webroot\forum and then set a "/forum/" redirect. The forum then loaded properly. So far so good.
The problem is that after disabling the redirect, just browsing the IP address on its own, still redirects to /forum and the forum loads. I even deleted web.config, but no difference, so I'm stumped. I expected it to error out without the redirect. I even deleted the "/forum/" text, but it still redirects. I've looked all round the IIS UI and ensured that there are no other redirects set, as far as I can see. Restarting Windows Server made no difference, either.
All I have at C:\webroot\ is that one forum folder, too. No default.htm, or anything else.
I have a similar test setup on my home Windows 10 PC, where turning the redirect on / off works as expected. The only difference there is that it has a simple test HTML page at C:\webroot\, the web.config file and some other files and folders left over from previous testing, so it loads that page instead without the redirect, which is as I expected.
The only real difference between the two operating systems is that Server 2019 is build 1809 while W10 is build 20H2, but I doubt that this is the cause. FYI I'd have updated Server 2019 to 20H2, but it's not possible for me to do it, but that's another story. If anyone has a solution to this, that it would be greatly appreciated.
Does anyone know why the redirect is doing this and how to fix it?
Monday, May 17, 2021 4:53 AM
Answers
-
User690216013 posted
I installed XenForo at C:\webroot\forum and then set a "/forum/" redirect.How did you set the redirect? Share more details please.
The problem is that after disabling the redirect, just browsing the IP address on its own, still redirects to /forum and the forum loads.- Use privacy mode of your web browser, so that you won't be redirected by cached rules at browser side.
- Enable FRT on IIS to see what generates the 30x redirection response https://docs.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis That's very important to learn the source of the unwanted redirection.
- Marked as answer by An0nym0u5User Friday, September 17, 2021 12:00 AM
Monday, May 17, 2021 2:53 PM
All replies
-
User690216013 posted
I installed XenForo at C:\webroot\forum and then set a "/forum/" redirect.How did you set the redirect? Share more details please.
The problem is that after disabling the redirect, just browsing the IP address on its own, still redirects to /forum and the forum loads.- Use privacy mode of your web browser, so that you won't be redirected by cached rules at browser side.
- Enable FRT on IIS to see what generates the 30x redirection response https://docs.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis That's very important to learn the source of the unwanted redirection.
- Marked as answer by An0nym0u5User Friday, September 17, 2021 12:00 AM
Monday, May 17, 2021 2:53 PM -
User939327180 posted
"How did you set the redirect? Share more details please."
I added the HTTP Redirect component to IIS.
I then set "/forum/" in the redirect requests to this destination field and enabled it with the tickbox.
I ticked only redirect requests to content in this directory (not subdirectories).
I set the status code to be a permanent redirect.
"1 Use privacy mode of your web browser, so that you won't be redirected by cached rules at browser side."
Well, this is a surprise. I'm using Firefox on the server for testing. I switched to Chrome, entered the IP and it errored out, as expected. Set the redirect, it worked, turned off the redirect, now it still redirects as if it was still set. Firefox and Chrome are both the latest versions. I didn't realise that browsers cache redirects. Now to make them stop caching this... clearing the cache on both browsers makes them forget the redirect until the next time I enable it. I need to turn cached mode off on the browsers.
Setting the status code to a temporary redirect makes no difference.
I did not expect this, because I've got the same browsers on W10, updated to the latest versions, which didn't behave this way.
- - Chrome now starts caching the redirect.
- - Firefox follows the redirect setting, displaying the page without the redirect if not redirected. It would probably behave the same way on the server if I put that test page there, too.
Stupid reason for going round in circles, but at least I know why now. Thanks for your help.
And thanks for that tracing link. I'll check it out.
EDIT: turned the cache off on Firefox and now the browser follows the redirect setting in IIS, as expected. Problem solved. I'll leave Chrome as it is for now. The problem was never with IIS.
Monday, May 17, 2021 11:37 PM