Url从mysite.com/home/重写为asp.net核心中的mysite.com/

时间:2016-11-04 16:16:58

标签: url asp.net-core url-rewriting

我在web.config中的重写规则正确地从“example.com/home”重定向到“example.com/”,但无法从“example.com/home/”重定向(唯一的区别是正向斜杠)后者)。我想知道如何让第二个例子起作用。我的web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
     <rewrite>
          <rules>
               <rule name="mysite.com/home or mysite.com/home/ to mysite.com/" stopProcessing="true">
                    <match url="(.*)\/?\bhome\/?\b$" />
                    <action type="Redirect" url="/" redirectType="Permanent"/>
               </rule>
          </rules>
    </rewrite>
    <handlers>
         <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>

0 个答案:

没有答案