【发布时间】:2013-06-07 20:53:25
【问题描述】:
我有以下 web.config URL 重写规则:
<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
<match url="^propertysearch\.asp$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^urlrewrite=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="propertysearch.asp?urlrewrite={R:1}" />
</rule>
问题在于它将它应用于所有内容,所以我想做的是更改匹配 url 语法以告诉它仅在 URL 中包含“-to-rent-in-”时运行,所以...
www.domain.com/villas-to-rent-in-florida
将符合条件并应用规则,但这不会
www.domain.com/testentry
我尝试了不同的变体,但总是出错:(
【问题讨论】:
-
-to-rent-in-可以在 url 中的任何位置还是仅在第一个/之前? -
感谢您回来。仅在第一个 / 之前。本质上,URL 将始终如下所示:www.domain.com/[property type]-to-rent-in-[location] 所以 www.domain.com/villas-to-rent-in-florida, www.domain。 com/apartments-to-rent-in-new-york 等希望对您有所帮助:)
-
我无法测试我在星期一之前发布的答案,所以如果它不起作用,请不要犹豫发表评论!
-
您好,非常感谢您 :)。可悲的是,它不太好用,当我访问其中一个网址时,它会提供一个暂时找不到的页面......非常抱歉 - 非常感谢您的帮助。
-
效果很好,感谢您为我这样做。非常感谢:)