簡體   English   中英

我們真的需要URL Rewrite模塊在IIS上托管角度應用程序嗎?

[英]Do we really need URL Rewrite module for hosting angular app on IIS?

對我們來說,Angular應用程序可以在IIS上未安裝URL重寫模塊的情況下運行。 我們是否需要URL重寫模塊才能在IIS上托管angular應用程序? 如果不安裝它,會有什么區別?

它適用於web.config下面。我只是評論了重寫部分並添加了
默認文件

<?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="/SCOAP/index.html" />
      </rule>
    </rules>
  </rewrite> -->
  <defaultDocument enabled="true">
         <files>
            <add value="index.html" />
         </files>
  </defaultDocument>
</system.webServer>

</configuration>

Angular主要用於編寫SPA。 因此,您可能會有“ / home”,“ / products”和其他應運行相同的角度應用程序的URL,但您的應用程序將呈現僅不同的內容。 因此,當用戶導航到“ yoursite.com/home”時,它應該看到Angular應用程序主頁。 並重寫,您將只看到404(因為/home.html中沒有源代碼)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM