301重定向仅针对根URL而不是该路由web.config的子目录

时间:2018-06-21 13:20:55

标签: asp.net redirect url-rewriting

我需要/ play重定向到索引页面,同时保留/ play的所有子目录。我似乎无法使它正常工作,以下是我正在尝试的操作,但没有成功。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <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"/>
    <rewrite>
      <rules>
        <clear />
        <!--<rule name="root play" stopProcessing="true" patternSyntax="ExactMatch">
                <match url="" ignoreCase="true"  /> 
                <action type="Redirect" url="/" redirectType="Permanent" /> 
            </rule>-->
        <rule name="WWW Rewrite" enabled="true">
          <match url="(.*)$"/>
          <conditions>
            <add input="{HTTP_HOST}" matchType="Pattern" pattern="^bellportgolfclub-staging.azurewebsites.net" negate="true" />
            <add input="{HTTP_HOST}" matchType="Pattern" pattern="^staging\." negate="true" />
            <add input="{HTTP_HOST}" matchType="Pattern" pattern="^www\." negate="true" />
            <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost" negate="true" />
          </conditions>
          <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
        <location path="play/(.*)$">
    <system.webServer>
      <httpRedirect enabled="true" destination="http://www.bellportgolfclub.com/" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>

</configuration>

0 个答案:

没有答案