1

背景:我正在使用 IIS 7 (Windows 2008) 和 Zend Framework

我正在做的是重写链接 site/blog?Id=1 到 site/blog/1 谁能告诉我为什么这不起作用?

<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
    <match url="^blog$" />
    <conditions>
        <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
        <add input="{QUERY_STRING}" pattern="^Id=([^=&amp;]+)$" />
    </conditions>
    <action type="Redirect" url="blog/{C:1}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
    <match url="^blog/([^/]+)/?$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="blog?Id={R:1}" />

提前致谢。

4

2 回答 2

2

改用这个作为zend doc中的提及

 <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
         <system.webServer>
             <rewrite>
                 <rules>
                     <rule name="Imported Rule 1" stopProcessing="true">
                         <match url="^.*$" />
                         <conditions logicalGrouping="MatchAny">
                             <add input="{REQUEST_FILENAME}"
                                 matchType="IsFile" pattern=""
                                 ignoreCase="false" />
                             <add input="{REQUEST_FILENAME}"
                                 matchType="IsDirectory"
                                 pattern="" ignoreCase="false" />
                         </conditions>
                         <action type="None" />
                     </rule>
                     <rule name="Imported Rule 2" stopProcessing="true">
                         <match url="^.*$" />
                         <action type="Rewrite" url="index.php" />
                     </rule>
                 </rules>
             </rewrite>
         </system.webServer>
    </configuration>

源代码

于 2012-06-29T06:30:57.713 回答
-1

在您的 .htaccess 文件中尝试以下代码:

RewriteRule    ^blog/([0-9]+)/?$    blog?id=$1    [NC,L]    # Handle requests
于 2012-06-29T06:14:15.993 回答