假設您在IIS 7上託管Wordpress,並且您想激活永久鏈接。縱觀抄本here,你會看到web.config文件(位於你的WordPress安裝的根目錄)這個例子的代碼在<system.webServer>
標籤添加:WordPress的Wordpress永久鏈接與WCF服務使用服務工廠
<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="index.php" />
</rule>
</rules>
</rewrite>
一切都很好,和網址重寫規則的條件正確地忽略系統上存在的現有文件和文件夾。
然而,你可能會到situtation,像我一樣,在這裏你需要忽略每一個處於某個子文件夾中的URI,即使沒有文件系統中的相應文件。在我來說,我使用的<serviceActivations>
面積在web.config中(在子目錄)的形式舉辦一系列WCF服務的子目錄/Services/
:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./AccountService.svc" service="MyAssembly.Services.AccountService"/>
</serviceActivations>
</serviceHostingEnvironment>
導航到AccountService.svc
會造成404未找到。
你如何處理這種情況?下面我發佈了我的具體解決方案,但還有其他方法可以實現這一點。此外,一般情況下的解決方案仍然是難以捉摸的,所以問題仍然存在,您通常如何處理這種情況?