英文:
How to deploy Angular 15 app with iis that has multiple apps
问题
我已经尝试更改index.html中的基本href
<base href="/AppName/">
我还添加了重定向配置。
<?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>
</system.webServer>
我已经查看了stackoverflow中的所有问题,但那里有很多与情况相关的无关信息,没有一个对我起作用。我只需要有人告诉我这样做,它会起作用
对我来说很不可思议的是,文档中没有提供这些信息,我们必须在问题和问题之间寻找解决方案。
英文:
I have tried changing the base href in index.html
<base href="/AppName/">
I have also added, the rerouting 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="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
I have gone through all of the questions in stackoverflow but there is a lot of irrelevant, case related info out there, and none of them worked for me. I just need someone to tell me do this and it will work
It is insane to me that this info is not given in the docs, and we have to jump through questions and issues to find the solution.
答案1
得分: 1
要将Angular应用程序部署为IIS应用程序,您可以按照以下步骤进行操作:
1)运行以下命令来构建Angular应用程序:
ng build --base-href='/basepath/'
基本路径将与IIS应用程序名称相同
2)在IIS中创建应用程序,并指向dist目录以及您的Angular构建路径,类似于以下方式:
C:\app-name\dist\app-name
3)在以下路径C:\app-name\dist\app-name创建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="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
注意:不要忘记将iis_iusrs和iusr用户分配权限给站点根文件夹。
英文:
To deploy the angular app in iis as application you can follow beelow steps:
- Run below command to build the angular app:
ng build --base-href='/basepath/'
base path will be the same app name as iis application name
- Create application in iis and point to the dist and your angular build path something like below:
C:\app-name\dist\app-name
-
Create web.config file as below at this path C:\app-name\dist\app-name:
<?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>
</system.webServer>
</configuration>
Note: Do not forgot to assign iis_iusrs and iusr user permission to the site root folder
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论