Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 从目录中提供图像,但可以通过不同的URL路径访问_Asp.net_Iis 7_Web Config_Azure Web App Service_Url Rewrite Module - Fatal编程技术网

Asp.net 从目录中提供图像,但可以通过不同的URL路径访问

Asp.net 从目录中提供图像,但可以通过不同的URL路径访问,asp.net,iis-7,web-config,azure-web-app-service,url-rewrite-module,Asp.net,Iis 7,Web Config,Azure Web App Service,Url Rewrite Module,如何在我的web.config中指定URL重写,从而从磁盘上的不同目录提供对映像的任何请求 图像位于目录site root\foo\bar\images中。通常通过http://site-root/foo/bar/images/ 我希望图像可以通过不同的URL访问,如http://site-root/img/ 例如: site-root\foo\bar\images\test.png 可于 http://site-root/img/test.png 我不需要对文件扩展名(png、gif、jp

如何在我的web.config中指定URL重写,从而从磁盘上的不同目录提供对映像的任何请求

图像位于目录
site root\foo\bar\images
中。通常通过
http://site-root/foo/bar/images/

我希望图像可以通过不同的URL访问,如
http://site-root/img/

例如:

site-root\foo\bar\images\test.png
可于

http://site-root/img/test.png
我不需要对文件扩展名(png、gif、jpg等)进行筛选,只需要从
img
请求的任何文件/资源从真实目录中读取即可

如何使用ASP.NET web.config URL重写或任何其他方法来实现此目的


我打算使用web.config解决方案,因为它将部署到Windows Azure网站。

我过去通过在IIS中设置虚拟目录将URL映射到特定文件夹来实现这一点。

使用此web.config重写规则

<system.webServer>
<rewrite>
  <rules>
    <rule name="Blog Images to Thier Real Location" stopProcessing="true">
      <match url="^img/(.*)" />
      <action type="Redirect" url="foo/bar/images/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>
</system.webServer>


谢谢你,大卫。很遗憾,我使用的是Windows Azure网站,因此无法创建虚拟目录。抱歉,我在您的问题中遗漏了这一点。