Web配置重写规则不显示正确的页面
我想重写一个Mediawiki网站中的网址,并且一切看起来正在根据失败的请求日志文件输出工作。然而,正在显示的页面是原始页面,而不是重写中的网址。基本上,我想www.website.com/State/City/Category
在www.website.com/index.php?title=Special:RunQuery/CategoryPage&CategoryPage[State]= State&CategoryPage[City]=City&CategoryPage[Category]=Category&wpRunQuery=true
而似乎是展示在www.website.com/index.php?title=State/City/Category
印刷_SERVER页面显示的页面显示QUERY_STRING作为特别:RunQuery页,但在其他方面所有其他变量显示index.php或/ State/City/Category。我的web.config重写规则看起来像这样:Web配置重写规则不显示正确的页面
<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=([^=&]+)$" />
</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&CategoryPage[State]={UrlDecode:{R:1}}&CategoryPage[City]={UrlDecode:{R:2}}&CategoryPage[Category]={UrlDecode:{R:3}}&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>
感谢任何帮助,以弄清楚这一个。现在我已经打了2天脑子。谢谢!
我想你的规则本地和他们的工作,你所指出的,要求: 测试:
RequestURL = “/州/市/分类”
将其正确改写为: “本地主机:80 /指数?.PHP标题=特殊:RunQuery/CategoryPage & CategoryPage [状态] =国家& CategoryPage [城市] =城市& CategoryPage [类别] =类别& wpRunQuery =真正的”
我的建议是使用失败请求跟踪: http://www.iis.net/learn/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules ,这应该告诉你到底发生了什么。
好吧,我想,因为卡洛斯说web.config看起来不错,它一定是Mediawiki,果然我找到了一个地方,它检查并使用$ _SERVER ['REQUEST_URI']。这可能会在URL的Rewrite for Apache中更改,但它不在IIS中。幸运的是我设法修改了LocalSettings.php中的一个变化,所以yay没有mod到核心代码。因此,如果其他人对IIS和Mediawiki或IIS和任何其他PHP Apache中心站点有此问题,则可以在以下代码中添加以下代码:
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'];
赞赏您检查出来。我尝试了失败的请求追踪,就像我上面所说的,一切似乎都没问题。在日志结尾处,它执行了一个看起来不错的重写操作,规则评估显示了新的查询字符串,重写结束显示了index.php的请求url,然后它向完整正确的字符串发出请求,然后以200成功。我想知道的是,也许Mediawiki正在寻找其他的东西,并根据其他变量提供不同的页面。 Request_URI仍然设置为/ State/City/Category。你可以改变web.config中的Request_URI和其他_Server变量吗? –