Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular IIS重定向到新URL_Angular_Redirect_Iis - Fatal编程技术网

Angular IIS重定向到新URL

Angular IIS重定向到新URL,angular,redirect,iis,Angular,Redirect,Iis,我正在尝试将Angular 7网站的用户从旧url重定向到新url,如下所示: 到 我使用的是IIS 8,但我无法确定要进行此更改的设置,同时在url中维护每个用户不同的数据,即“NjUxMzExNC83MzQx”部分 我在“v1”版本中尝试了下面的web.config设置,以将用户传递到“v2”,但这不起作用 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer>

我正在尝试将Angular 7网站的用户从旧url重定向到新url,如下所示:

我使用的是IIS 8,但我无法确定要进行此更改的设置,同时在url中维护每个用户不同的数据,即“NjUxMzExNC83MzQx”部分

我在“v1”版本中尝试了下面的web.config设置,以将用户传递到“v2”,但这不起作用

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<system.webServer>
  <rewrite>
    <rules>
      <rule name="Angular Routes" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAll">
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="./index.html" />
      </rule>
    </rules>
  </rewrite>
  <httpRedirect enabled="false" destination="v2/" exactDestination="false" />
</system.webServer>

请尝试此规则

如果需要将v1重定向到v2,请选择type=“redirect”而不是“重写”

  <rule name="redirect rule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{URL}" pattern="^/v1(/page/[a-zA-Z0-9]+)$" />
                    </conditions>
                    <action type="Redirect" url="v2{C:1}" redirectType="Temporary" />
                </rule>

编辑:



谢谢你的帮助,我认为它几乎可以工作了,但还不够。当我输入url时,我可以看到它在大约半秒钟内从这个转到这个,然后再转到这个,这是否与角度规则相冲突?我先得到这个,然后是角度的。我担心编辑的版本不起作用,它只是重复了很多次。另外,我现在已经删除了角度规则,因为这不是必需的,它只是停留在example.com/v1/v2/page/NjUxMzExNC83MzQx上now@fosbie我知道问题出在哪里。您是否将v1和v2作为虚拟应用程序托管?如果是这样,重定向将误解相对路径v2/{C:1}。我已经更新了规则。请检查它是否工作只是为了清楚,我只是添加了一个“s”使http成为https
   <rule name="redirect rule" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{URL}" pattern="^/v1(/page/[a-zA-Z0-9]+)$" />
                    </conditions>
                    <serverVariables />
                    <action type="Redirect" url="http://{HTTP_HOST}/v2{C:1}" redirectType="Temporary" />
                </rule>