[英]IIS Reverse Proxy for specific URL path - URL Rewrite Module Error
[英]IIS URL Rewrite: Rewrite if file in specific path doesn't exist
我對IIS的URL重寫模塊有一個看似簡單的要求,但似乎無法為單頁Web應用程序工作。 我有一個根文件夾content
並且里面有一個文件夾dashboard
。 URL在根目錄使用dashboard
(即,URL省略了content
)。 如果URL匹配任何文件,我希望它可以提供該文件,否則,我希望它可以提供顯示板文件夾中的index.html
。 唯一的麻煩是,儀表板位於文件系統中的content
文件夾內,但URL中不存在content
。
這是我的文件夾結構:
/content/dashboard/foo.txt
>為網址提供此服務: /dashboard/foo.txt
/content/dashboard/assets/image.jpg
>為網址提供此服務: /dashboard/assets/image.jpg
/content/dashboard/index.html
>如果沒有與/dashboard/
匹配的文件,則將其提供給所有以/dashboard/
開頭的URL
這是我的重寫規則:
<rules>
<rule name="dashboard assets" stopProcessing="true">
<match url="^dashboard(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="content/{REQUEST_FILENAME}" matchType="IsFile" negate="false" />
</conditions>
<action type="Rewrite" url="content/dashboard{R:1}" />
</rule>
<rule name="dashboard app" stopProcessing="true">
<match url="^dashboard(.*)$" />
<action type="Rewrite" url="content/dashboard/index.html" />
</rule>
</rules>
即使我具有上面的dashboard assets
條件,它似乎也從未使用過,並且始終提供index.html。 我該如何糾正?
{REQUEST_FILENAME}返回所請求文件的完整本地目錄路徑。 例如/content/dashboard/assets/image.jpg變量{REQUEST_FILENAME}實際上是C:\\ inetpub \\ wwwroot \\ content \\ dashboard \\ assets \\ image.jpg
從條件輸入中刪除內容/,它應該可以正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.