【发布时间】:2015-09-25 17:55:35
【问题描述】:
我在 IIS 服务器虚拟目录上托管多个应用程序,并且我正在使用 URL 重写来简化它们。像 "~/path/to/my/content" 这样手动编写的所有图像和其他资产都有正确的输出 "/path/to/my/content",但像 "~/client/js" 这样的捆绑路径给出的输出 "/myapplication/client/js" 应该是 "/client/js"。
我该如何解决这个问题?
我如何启动脚本包:
var scriptBundle = new ScriptBundle("~/client/js");
重写配置:
<rule name="Official Website" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" matchType="Pattern" pattern="^(www\.)?domain\.com$" ignoreCase="true" negate="false" />
</conditions>
<action type="Rewrite" url="officialsite/{R:1}" />
</rule>
正在研究这些主题,但无法为我做任何事情:
- How do I get System.Web.Optimization bundles to work with custom folders in an IIS virtual directory?
- CssRewriteUrlTransform with or without virtual directory
- Why does ResolveBundleUrl not work for custom folders? (MVC Beta 4)
- Is it possible to unit test BundleConfig in MVC4?
更新:我使用 Winhost 作为主机提供商,他们不支持为 IP 设置主机头,可能是由于共享 IP。它们提供指向根文件夹的域指针,这就是我使用 URL 重写的原因。
【问题讨论】:
-
您告诉我们您正在重写,但您决定不显示您的重写规则?看起来他们可能是问题的一部分。
-
在我看来,您想使用多个链接到端口 80 并通过主机名进行区分的网站。您不需要为此使用 URL 重写。 this 能成为你所追求的吗?
-
@milanio 嗨,我使用 winhost 作为我的托管服务提供商,我唯一能做的就是将域指针设置为适当的根文件夹。他们不提供像您提供的链接那样设置主机标头。谢谢你。
标签: asp.net-mvc url-rewriting iis-7 bundling-and-minification virtual-directory