![](/img/trans.png)
[英]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.