使用ColdFusion重写IIS URL会保留重复的字符串

使用ColdFusion重写IIS URL会保留重复的字符串,iis,url-rewriting,coldfusion,Iis,Url Rewriting,Coldfusion,我已经设置了一个URL重写,当我手动设置或键入URL时,它可以正常工作。但是,例如,当我在标签内的页面中使用链接时,该链接会复制字符串 我正在将ColdFusion 2016与IIS 10一起使用 例如,URL是 www.site.com/results.cfm?lang=1&categoryid=2&budegtid=all&typeid=all&propertyid=316 我希望它能像这样输出 www.site.com/properties/en/all/all/all/316 它的工作,

我已经设置了一个URL重写,当我手动设置或键入URL时,它可以正常工作。但是,例如,当我在标签内的页面中使用链接时,该链接会复制字符串

我正在将ColdFusion 2016与IIS 10一起使用

例如,URL是

www.site.com/results.cfm?lang=1&categoryid=2&budegtid=all&typeid=all&propertyid=316

我希望它能像这样输出

www.site.com/properties/en/all/all/all/316

它的工作,但什么似乎发生了当我设置链接使用。。。 正在使用查询

<cfif getProps.recordcount>
<cfoutput query = "getProps" startrow="#url.start#" maxrows="#perpage#">
<a href="property/#lang#/#category_id#/#budgetid#/#typeid#/#getProps.property_id#" id="listVewButton">View</a>
</cfoutput>
ColdFusion cfquery如下所示

<cfquery name="getProps" datasource="#session.odbcname#">
SELECT  *
FROM    properties P
INNER JOIN areas A
ON      A.area_id = P.property_areaid
INNER JOIN categories C
ON      C.category_id = P.property_propcategoryid
INNER JOIN  price R
ON      R.price_id = P.property_regularity
INNER JOIN types T
ON      T.type_id = P.property_proptypeid
WHERE   P.property_status != 'Off Market'
<cfif url.ref is not "all">
    AND     
        (
        property_ref like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
        OR property_refid like  <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
        OR property_town like  <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
        )
</cfif>
ORDER   BY P.property_refid
它似乎是先拉入实际的URL,然后再添加重写


非常感谢您的帮助。

已解决!通过在coldfusion应用程序文件中预先设置URL根,即,然后在链接中引用request.root变量,它可以正确使用链接,并且不会复制URL。因此,这是一个冷融合问题,而不是URL重写问题。

您需要以正斜杠开始href,以指示它来自根。href在浏览器中解析/解释。不以正斜杠开头会告诉浏览器url是相对于当前路径的

如果你在http://example.com/admin/ 并有一个href注销,例如,它将被解析为http://example.com/admin/logout. 但是,如果您有href/logout,它将解析为'http://example.com/logout.


正如你自己的回答所说,强制一条绝对路径是可行的,有时是可取的,但有时不是。确保您了解潜在问题。

阅读FRT了解更多信息这更可能与您的CFO输出有关。如果嵌套错误,它们将复制输出。i、 在cfoutput循环中显示更多的CF代码。嗨,我现在已经更新了帖子并添加了CF代码。感谢url重写不会对代码产生任何影响。检查浏览器中的链接,查看是否看到相同的URL。如果它在检查中加倍,那么它与URL重写无关。您确定在该cfoutput循环中没有cfoutput标记吗?您好,对不起,我现在添加了正确的URL webconfig
<cfquery name="getProps" datasource="#session.odbcname#">
SELECT  *
FROM    properties P
INNER JOIN areas A
ON      A.area_id = P.property_areaid
INNER JOIN categories C
ON      C.category_id = P.property_propcategoryid
INNER JOIN  price R
ON      R.price_id = P.property_regularity
INNER JOIN types T
ON      T.type_id = P.property_proptypeid
WHERE   P.property_status != 'Off Market'
<cfif url.ref is not "all">
    AND     
        (
        property_ref like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
        OR property_refid like  <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
        OR property_town like  <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
        )
</cfif>
ORDER   BY P.property_refid