问题
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.
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
},
...
回答1:
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>
来源:https://stackoverflow.com/questions/46812148/angular-4-403-forbidden-on-route-parameter-with-iis