我在IIS10中托管了MediaWiki安装。我正在尝试使用URL重写模块从某些MediaWiki文章URL中删除名称空间前缀。
- 在MediaWiki中,“主”命名空间之外的文章显示为
foo.com/wiki/Namespace:Article_Title
- 我只需要删除'Bar:'命名空间前缀,其他名称可以保持不变
- 限制:我无法将这些文章移入Main名称空间
所需结果将显示foo.com/wiki/Bar:Article_Title
中的内容,但显示为foo.com/wiki/Article_Title
。
现有入站URL重写
我每个Microsoft's doc for MediaWiki on IIS都有一个URL重写,它从URL中删除了查询字符串。这是基于该指导的我的重写规则:
<rule name="Clean-WikiArticlePages" stopProcessing="false">
<match url="^wiki/(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/w/index.php?title={UrlEncode:{R:1}}" />
</rule>
到目前为止我尝试过的事情
我尝试了入站和出站规则,都没有效果。
入站规则:
<rule name="Clean-Namespace" enabled="true">
<match url="^wiki/(Meetings:)(.*)" />
<action type="Rewrite" url="/wiki/{R:2}" />
</rule>
出站规则:
<outboundRules>
<rule name="Remove-Namespace" preCondition="IsHTML" enabled="true">
<match filterByTags="A" pattern="^wiki/Bar:(.*)" />
<action type="Rewrite" value="/wiki/{R:1}" />
</rule>
<preConditions>
<preCondition name="IsHTML">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>