Iis URL重写无法使用特定后缀

Iis URL重写无法使用特定后缀,iis,iis-7,url-rewriting,Iis,Iis 7,Url Rewriting,我正在将我的博客从LAMP/PHP迁移到IIS。为了保留URL,我使用URL重写模块。192页中,191页有效。本质上,我需要用目录名替换URL的“index.php”部分,并附加一个“.html”后缀 我的正则表达式模式: ^myblog/index\.php/(.+) 我的重写URL: myblog/contents/{R:1}.html 在大多数情况下,重写都是有效的 http://www.MYSITE/myblog/index.php/2013/04/29/goto_slides

我正在将我的博客从LAMP/PHP迁移到IIS。为了保留URL,我使用URL重写模块。192页中,191页有效。本质上,我需要用目录名替换URL的“index.php”部分,并附加一个“.html”后缀

我的正则表达式模式:

^myblog/index\.php/(.+)
我的重写URL:

myblog/contents/{R:1}.html
在大多数情况下,重写都是有效的

http://www.MYSITE/myblog/index.php/2013/04/29/goto_slides

但是,在一种情况下,它失败了:

http://www.MYSITE/myblog/index.php/2013/04/29/goto_notes_evolving_java
返回404,错误页面显示请求的URL为:

http://MYSITE:80/myblog/contents/2013/04/29/goto_notes_evolving_java
(请注意,未添加“.html”后缀;添加将查找页面。)

我能看到的唯一区别是URL的尾随“java”,它可以工作,也可以不工作

我如何解决这个问题


web.config,每个请求:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <rewrite>
            <rules>
                <clear />
                <rule name="Rewrite blog URL from old PHP location" stopProcessing="true">
                    <match url="^myblog/index\.php/(.+)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="myblog/contents/{R:1}.html" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

删除该条件将解决您的问题。
您的规则将成为:

<rule name="Rewrite blog URL from old PHP location" stopProcessing="true">
    <match url="^myblog/index\.php/(.+)" />
    <action type="Rewrite" url="myblog/contents/{R:1}.html" appendQueryString="true" />
</rule>


您是否可以发布您正在使用的确切规则(如果规则不止一条)(从web.config复制/粘贴)?你的代码中有重定向/重写吗?我看不出第二个url会失败的原因…@cheesemacfly Done。而且没有代码——这些是非常基本的HTML/CSS页面,没有重定向、JavaScript等。我真的不知道这个问题从何而来。能否尝试删除
?它不应该改变任何东西,但这里没有使用,所以…你能运行并将结果发布到internet上的某个地方,看看是否有任何异常(如果你能记录两个请求:一个正常,一个不正常)?@cheesemacfly“此网站未启用失败的请求跟踪”-我无权更改它(商业托管)。@cheesemacfly删除条件修复了它!谢谢!将其作为答案发布,我将接受它。
<rule name="Rewrite blog URL from old PHP location" stopProcessing="true">
    <match url="^myblog/index\.php/(.+)" />
    <action type="Rewrite" url="myblog/contents/{R:1}.html" appendQueryString="true" />
</rule>