IIS 7没有图像时,友好的网址是

问题描述:

我使用两个简单的规则来实现友好的网址。IIS 7没有图像时,友好的网址是

他们正在努力找到,但我看不到图像,并有一个错误

Friednly ASP.NET 3.5网站的URL

http://localhost/Test/Products/888/9999 

错误

http://localhost/Test/Products/888/Images/Jellyfish.jpg无法加载 资源:服务器与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}&amp;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> 

我看到IIS是建立错误的道路像它的图像说

http://localhost/Test/Products/888/Images/Jellyfish.jpg

任何线索?

+0

我不完全理解。除了http:// localhost/Test/Products/888/9999'之外,你还可以在位置“http:// localhost/Test/Products/888/Images/Jellyfish.jpg”中返回图片,还是你的产品.aspx返回一个图像。什么是你想要得到的图像的真实网址? –

+0

@PeterHahndorf Url'http:// localhost/Test/Products/888/9999'是打开Products.aspx。但不知何故,IIS正在重写这个页面内部图像的路径。这个页面有一个简单的'',它工作的很好,没有重写规则。 –

+1

所以图像的src是相对于页面的,浏览器会请求类似于'http://localhost/Test/Products/888/9999/images/jellyfish.jpg'的东西,这是由你的重写规则拾取的。在F12浏览器工具中,检查图像的实际请求的URL。您必须从规则中排除图像或使用非相对路径。 –

最后我找到了答案在这里Missing CSS file and images after URL rewrite

我们在母版的标题使用此行

<base href="//your.domain.here" /> 

你可以阅读在这里http://www.w3schools.com/tags/tag_base.asp