How to do IIS 301 redirect

should I delete the stuff that’s currently in the <system.webServer> tags?

You need to combine the things from both. Somethng like

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <httpErrors>
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="/handle404.html" responseMode="ExecuteURL" />
    </httpErrors>
    <rewrite>
        <rules>
          <rule name="WorkForceProductivitySolutions" stopProcessing="true">
            <match url="/workForce_Productivity_Solutions.htm" />
            <action type="Permanent" url="/SupplyChainSolutions.html" />
          </rule>
        </rules>
      </rewrite>
</system.webServer>
</configuration>

i get a 500 internal server error

Does anyone have any other ideas for how to redirect this page?

Can you post what you had in your web.config file that caused the 500 error? There may have been a typo or something similar which can be fixed.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <httpErrors>
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="/handle404.html" responseMode="ExecuteURL" />
    </httpErrors>
      <rewrite>
    <rules>
      <rule name="WorkForceProductivitySolutions" stopProcessing="true">
        <match url="/workForce_Productivity_Solutions.htm" />
        <action type="Permanent" url="/SupplyChainSolutions.html" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>
</configuration>

I admit I have no idea, but this looks like a possible area to look into
prefixLanguageFilePath=""

prefixLanguageFilePath Optional string attribute.

Specifies the initial path segment when generating the path for a custom error. This segment appears before the language-specific portion of the custom error path. For example, in the path C:\Inetpub\Custerr\en-us\404.htm, C:\Inetpub\Custerr is the prefixLanguageFilePath.

I’m going to need some more guidance. The site is hosted on IIS. I need to redirect one .html file to another. How do I do this?? Someone out there must have done this before, no?

I recategorized this to General Web Dev, but I don’t think it will make much of a difference. We’ve tried everything we know. You might want to try and find an IIS specific forum that you can ask this question on.

I have to say, I do always struggle with IIS web.config, I try things that should work, but it gives a server error, and finding help is not easy.
Another way to do a 301 is with wildcards.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
      <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Permanent">
         <add wildcard="/workForce_Productivity_Solutions*" destination="/SupplyChainSolutions.html" />
      </httpRedirect>
</configuration>

Try putting the httpRedirect part inside the configuration part of your web.config.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.