2015-09-15 80 views
0

我的項目使用php和angular,它託管在IIS中。我打開html5Mode角度,這意味着我可以使用像localhost/home而不是locahost/#/home路線。如何配置IIS重寫

我的問題是,當我複製&通過網址(例如:http://localhost/home)到另一個選項卡或瀏覽器,IIS返回錯誤

Requested URL http://localhost/home/

Physical Path <physical link>\link\

我想採用了棱角分明的路線(不ui-router)來處理我的應用程序中的所有路線。我如何配置URL Rewrite才能讓它理解所有隻需要指向home的路線?

我的項目路線是index.html。這是一個正常的html文件。

在Asp.net MVC,我的配置像這樣的路線:

routes.MapRoute(
       name: "Renewal SPA", 
       url: "{*catchall}", 
       defaults: new { controller = "Home", action = "Index" }); 

如何做相同的php

回答

1

你應該配置IIS在您的配置文件(或IIS)這樣的重寫:

<system.webServer> 
<rewrite> 
<rules> 
    <rule name="Main Rule" 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> 

確保URL重寫安裝在您的IIS(從here下載)。

看到這篇文章: Configure your server to work with html5Mode