本文介绍了IIS禁止在Angular 4403路由参数上使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用IIS版本6.1 SP1将Angular项目部署到我们的开发环境中,并且在route参数上收到403 Forbidden错误.在我的网址中,客户端"不是组件,而是路由参数.该项目在我的本地主机上运行良好,只有在将代码推送到我们的开发环境时问题才出现.
I deployed my Angular project to our dev environment using IIS Version 6.1 SP1 and I'm getting 403 Forbidden error on my route parameter. In my URL, the "client" is not a component but a route parameter. The project works perfectly fine on my localhost, the issue is only when I pushed the code to our development environment.
这是我在app.routes.ts中的代码:
Here is my code in app.routes.ts:
const routes: Routes = [
{
path: '',
redirectTo: 'login',
pathMatch: 'full'
},
{
path: 'login',
component: LoginComponent
},
{
path: 'login/:licenseeCode',
component: LoginComponent
},
...
推荐答案
如果您部署到文件夹(不是根目录),则可能需要调整
if you deployed to a folder (NOT ROOT) you might need to adjust your
<base href="/FOLDER_WHERE_YOU_DEPLOYED/" />
还尝试将其添加到您的配置文件中:
also try adding this to your config file:
<system.webServer>
<rewrite>
<rules>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/FOLDER_WHERE_YOU_DEPLOYED/" />
</rule>
</rules>
</rewrite>
</system.webServer>
这篇关于IIS禁止在Angular 4403路由参数上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!