我正准备对我们的购物车进行一次大修,这将彻底改变urls的结构。无论它的价值是什么,这是Magento 1.7的。
示例网址为:{domain}/item/sub-domain/sub-sub-domain-5-16-7-16-/8083770?plpver=98&categid=1027&prodid=8090&origin=keyword
并将其重定向到{domain}/catalogsearch/result/?q=8083710
我的web.config是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Magento Required" stopProcessing="false">
<match url=".*" ignoreCase="false" /> <conditions>
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions> <action type="Rewrite" url="index.php" />
</rule>
<rule name="Item Redirect" stopProcessing="true">
<match url="^item/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)(\?.*)" />
<action type="Redirect" url="catalogsearch/result/?q={R:3}" appendQueryString="true" redirectType="Permanent" />
<conditions trackAllCaptures="true">
</conditions>
</rule>
</rules>
</rewrite>
<httpProtocol allowKeepAlive="false" />
<caching enabled="false" />
<urlCompression doDynamicCompression="true" />
</system.webServer>
</configuration>现在,重定向似乎完全被忽略了,即使在IIS GUI中,示例url通过了正则表达式测试。有没有更好的重定向方法,或者我的web.config出了什么问题?
发布于 2013-06-25 03:38:10
事实证明答案是here。正则表达式中不能有问号,因为IIS将其视为查询字符串,并且需要在web.config的"conditions“部分中捕获它。
因此,我只是去掉了正则表达式的末尾的(\?.*),并添加了:
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern=".*" />
</conditions>https://stackoverflow.com/questions/17280210
复制相似问题