IIS部署React.js localHost可以訪問 ip訪問404問題

在生成的dist目錄下 新增web.config文件

內容如下:

<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="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
  </configuration>

IIS需要安裝URL ReWrite模塊

下載地址:https://www.iis.net/downloads/microsoft/url-rewrite

安裝成功後,IIS首頁顯示如下圖,重啓對應網站即可

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章