【发布时间】:2020-01-13 22:14:44
【问题描述】:
我已经设置了一个 URL 重写,当我手动设置或输入 URL 时它可以正常工作。但是,当我在页面中使用 <cfoutput> 标记中的链接时,该链接会复制字符串。
我正在使用带有 IIS 10 的 ColdFusion 2016
例如网址是
www.site.com/results.cfm?lang=1&categoryid=2&budegtid=all&typeid=all&propertyid=316
我希望它像这样输出
www.site.com/properties/en/all/all/all/316
它可以工作,但是当我使用...设置链接时似乎发生了什么
<cfoutput> 使用查询...
<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>
页面链接中的结果输出为www.site.com/properties/en/all/all/all/316/properties/en/all/all/all/316
我已将 web/config 设置为
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<rewrite>
<rules>
<rule name="Property list URL rewrite">
<match url="^property/([_0-9a-z-]+)/([_0-9a-z-]+)/budget-range-([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="resultsproperty.cfm?lang={R:1}&categoryid={R:2}&budegtid={R:3}&typeid={R:4}&propertyid={R:5}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
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,然后再添加重写。
非常感谢任何帮助。
【问题讨论】:
-
这更有可能与您的 CFOUTPUT 有关。如果它们嵌套错误,它们将复制输出。即在 cfoutput “循环”中 - 显示更多 CF 代码。
-
嗨,我现在已经更新了帖子并添加了 CF 代码。谢谢
-
url 重写不会对代码做任何事情。检查浏览器中的链接,看看您是否看到相同的 URL。如果它在检查中翻了一番,那么它与 URL 重写无关。您确定在 cfoutput 循环中没有 cfoutput 标签吗?
-
您好,抱歉,我现在添加了正确的 URL webconfig
标签: iis url-rewriting coldfusion