0

我正在准备对我们的购物车进行大修,这将彻底改变 URL 的结构。对于它的价值,这适用于 Magento 1.7。

一个示例 URL 是: {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 有问题?

4

1 回答 1

0

原来答案就在这里。正则表达式中不能有问号,因为 IIS 将其视为查询字符串,需要在 web.config 的“条件”部分中捕获。

所以我刚刚(\?.*)取消了正则表达式的结尾,并添加了:

<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
    <add input="{QUERY_STRING}" pattern=".*" />
</conditions>
于 2013-06-24T19:38:10.380 回答