Iis Web配置重写规则未显示正确的页面

Iis Web配置重写规则未显示正确的页面,iis,url-rewriting,web-config,iis-7.5,mediawiki,Iis,Url Rewriting,Web Config,Iis 7.5,Mediawiki,我正在尝试重写Mediawiki站点中的url,根据失败的请求日志文件输出,所有内容看起来都正常工作。然而,显示的页面是原始页面,而不是重写中的url。基本上我想要 www.website.com/State/City/Category以显示以下页面: www.website.com/index.php?title=Special:RunQuery/CategoryPage&CategoryPage[州]= State&CategoryPage[City]=城市&CategoryPage[Cat

我正在尝试重写Mediawiki站点中的url,根据失败的请求日志文件输出,所有内容看起来都正常工作。然而,显示的页面是原始页面,而不是重写中的url。基本上我想要 www.website.com/State/City/Category以显示以下页面: www.website.com/index.php?title=Special:RunQuery/CategoryPage&CategoryPage[州]= State&CategoryPage[City]=城市&CategoryPage[Category]=类别&wpRunQuery=true 相反,它似乎在显示页面 www.website.com/index.php?title=State/City/Category printing _SERVER将QUERY_字符串显示为Special:RunQuery页面,但其他所有变量显示index.php或/State/City/Category。我的web.config重写规则如下所示:

<rewrite>
    <rules>
        <rule name="Root Hit Redirect" stopProcessing="true">
            <match url="^$" />
            <action type="Rewrite" url="/index.php?title=Main_Page" />
        </rule>
       <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
           <match url="^index\.php$" />
           <conditions>
               <add input="{REQUEST_METHOD}" pattern="^POST$" />
               <add input="{QUERY_STRING}" pattern="^title=([^=&amp;]+)$" />
           </conditions>
           <action type="Redirect" url="{C:1}" appendQueryString="false" />
       </rule>
       <rule name="RewriteUserFriendlyCategoryURL" stopProcessing="true">
            <match url="^([^/]+)/([^/]+)/([^/]+)/?$" />
            <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php?title=Special:RunQuery/CategoryPage&amp;CategoryPage[State]={UrlDecode:{R:1}}&amp;CategoryPage[City]={UrlDecode:{R:2}}&amp;CategoryPage[Category]={UrlDecode:{R:3}}&amp;wpRunQuery=true" />
        </rule>
       <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
           <match url="^(.+)$" />
           <conditions>
               <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
               <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
           </conditions>
           <action type="Rewrite" url="index.php?title={UrlDecode:{R:1}}" />
       </rule>
    </rules>
</rewrite>

感谢大家帮我弄明白这件事。已经绞尽脑汁两天了。谢谢

我在本地尝试了您的规则,它们按照您的指示工作,请求: 测试: RequestURL=/State/City/Category

将正确地将其重写为: localhost:80/index.php?title=Special:RunQuery/CategoryPage&CategoryPage[State]=State&CategoryPage[City]=City&CategoryPage[Category]=Category&wpRunQuery=true

我的建议是使用失败的请求跟踪:
这应该会告诉你到底发生了什么。

好吧,我想既然Carlos说web.config看起来不错,那一定是Mediawiki,我找到了一个地方,它可以检查并使用$服务器['REQUEST\u URI']。这可能会在Apache的URL重写时更改,但它不在IIS中。幸运的是,我在LocalSettings.php中做了一个更改,成功地解决了这个问题,因此,对于核心代码没有mod是很好的。因此,如果其他任何人在IIS和Mediawiki,或IIS和任何其他以PHP Apache为中心的站点上有此问题,您可以在下面添加此代码:

$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'];

谢谢你的检查。我尝试了失败的请求跟踪,正如我上面所说的,一切看起来都正常。在日志的末尾,它执行了一个看起来不错的重写操作,规则评估显示了新的查询字符串,重写结束显示了index.php的请求url,然后它向完全正确的字符串发出请求,然后以200成功结束。我想知道的是,也许Mediawiki正在寻找其他东西,并基于其他变量提供不同的页面。请求URI仍然设置为/State/City/Category。您可以在web.config中更改请求URI和其他服务器变量吗?