【问题标题】:Rewrite images directory IIS重写图像目录 IIS
【发布时间】:2013-08-15 07:23:20
【问题描述】:

我们正在将旧应用程序迁移到 ASP.NET MVC,但在旧应用程序中,图像文件夹位于应用程序的根目录中,因此要引用图像,路径将是 /images/imagename.png,但我们希望将图像移动到新应用程序中的 /Content/images 中,但我们不想更改所有 css 和 html 中的路径。

有没有办法对图像文件夹进行重写,以便转到 /images 的每个 URL 都转到 /Content/images?

【问题讨论】:

    标签: asp.net-mvc iis url-rewriting


    【解决方案1】:

    使用 URL 重写。您需要通过 WebPI 安装它,然后在 system.webServer 中的 web.config 中添加以下内容:

     <rewrite>
        <rule name="Old Images" stopProcessing="true">
          <match url="^images/(.+)$" ignoreCase="true" />
          <action type="Rewrite" url="content/images/{R:1}" appendQueryString="true" />
        </rule>
     </rewrite>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-09
      • 2022-11-17
      • 2017-05-08
      • 1970-01-01
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多