Asp.net 启用友好url时,IIS 7没有图像
我使用两个简单的规则来实现友好的url 他们正在查找,但我看不到图像,并且出现了错误 ASP.NET 3.5网站的唯一URLAsp.net 启用友好url时,IIS 7没有图像,asp.net,iis-7,friendly-url,url-rewrite-module,Asp.net,Iis 7,Friendly Url,Url Rewrite Module,我使用两个简单的规则来实现友好的url 他们正在查找,但我看不到图像,并且出现了错误 ASP.NET 3.5网站的唯一URL http://localhost/Test/Products/888/9999 错误 加载失败 资源:服务器响应状态为404(未找到) 规则 <rule name="t2" enabled="true"> <match url="^products/([0-9]+)/([0-9]+)" negate="fal
http://localhost/Test/Products/888/9999
错误
加载失败
资源:服务器响应状态为404(未找到)
规则
<rule name="t2" enabled="true">
<match url="^products/([0-9]+)/([0-9]+)" negate="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="products.aspx?p={R:1}&pc={R:2}" />
</rule>
<rule name="t1" enabled="true">
<match url="^product/([0-9]+)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="product.aspx?p={R:1}" />
</rule>
有什么线索吗?我终于在这里找到了答案
我们必须在母版的页眉中使用这一行
<base href="//your.domain.here" />
你可以在这里读到它我不完全明白。除了urlhttp://localhost/Test/Products/888/9999
返回位置的图像http://localhost/Test/Products/888/Images/Jellyfish.jpg
,或者您的product.aspx返回图像。你想要得到的图像的真实url是什么?@PeterHahndorf-the-urlhttp://localhost/Test/Products/888/9999
打开Products.aspx。但不知怎的,IIS正在重写此页面内图像的路径。此页面有一个简单的“``可以正常工作,无需重写规则。因此,图像的src与页面相关,浏览器将请求类似于“`”的内容,这是由您的重写规则获取的。在F12浏览器工具中,检查图像的实际请求url。您必须从规则中排除图像,或者使用非相对路径。@PeterHahndorf我该怎么做?您可以在规则中添加一个条件,如
,或者
,您必须确保图像与规则不匹配。