代码之家  ›  专栏  ›  技术社区  ›  geoff swartz

如何修复不起作用的web.config重定向

  •  0
  • geoff swartz  · 技术社区  · 1 年前

    我正在尝试使用web.config文件进行重定向。httpRedirect规则可以正常工作,但rewrite规则不行。我得到一个500的错误。如果我转到IIS HTTP重定向部分,我会看到下图中的内容。如果删除重写节点,它会在IIS HTTP重定向窗口中正常打开。我在这里做错了什么?

    enter image description here

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.7.2" />
        <httpRuntime targetFramework="4.7.2" />
      </system.web>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="rewrite_client_contract" stopProcessing="true">
                        <match url="^client/contractreview/index/(.*)" />
                        <action type="Redirect" url="https://adumbsite.com/contractreview/index/{R:1}" appendQueryString="false" redirectType="Permanent" />
                    </rule>
                </rules>
            </rewrite>
            <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Permanent">
                <add wildcard="/public/signup" destination="https://adumbsite.com/sign-up/" />
            </httpRedirect>
        </system.webServer>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
        </compilers>
      </system.codedom>
        <system.web>
            <customErrors mode="Off"/>
        </system.web>
    </configuration>
    
    0 回复  |  直到 1 年前