IIS7和URLRewrite与WordPress 3.1.1redirect失败

我在迁移到wordpress 3.1.1多站点和url重写规则时遇到了一个有趣的问题。 index.php路由,以及ms-files.php?file =规则在整个板上都失败了。 当你通过index.php发送永久链接时,ROOT站点具有可以工作的function。 (编辑:这在networking站点也很普遍,从我所看到的规则7是这里失败的罪魁祸首。)

媒体(规则2)的规则也失败了。 生成的链接正在拉回一个“哎呀不能find”404风格的错误。

一切看起来都正确的规则部分,如下所示:

<rule name="WordPress Rule 1" stopProcessing="true"> <match url="^index\.php$" ignoreCase="false" /> <action type="None" /> </rule> <rule name="WordPress Rule 2" stopProcessing="true"> <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" /> <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" /> </rule> <rule name="WordPress Rule 3" stopProcessing="true"> <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" /> <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" /> </rule> <rule name="WordPress Rule 4" stopProcessing="true"> <match url="^" ignoreCase="false" /> <conditions logicalGrouping="MatchAny"> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> </conditions> <action type="None" /> </rule> <rule name="WordPress Rule 5" stopProcessing="true"> <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" /> <action type="Rewrite" url="{R:1}" /> </rule> <rule name="WordPress Rule 6" stopProcessing="true"> <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> <action type="Rewrite" url="{R:2}" /> </rule> <rule name="WordPress Rule 7" stopProcessing="true"> <match url="." ignoreCase="false" /> <action type="Rewrite" url="index.php" /> </rule> 

你可以通过观看来查看展示的行为: UB News Staging site 1 UB News Staging Site 2

注意分段站点2媒体如何不能正常工作。 但是,当您访问以下链接时,格式正在工作,照片显示应该如此。 http://staging.business-school-online.com/news/wp-includes/ms-files.php?file=2011/04/online-education-300×198.jpg

编辑:WP生成的链接是http://staging.business-school-online.com/news/files/2011/04/online-education-300×198.jpg

有人可以提供一些洞察失败的url重写规则? 根据正则expression式的结构是正确的。 正则表达式

我没有使用wordpress链接本身,但让我们从媒体规则开始吧。 似乎有两件事情在行动中失踪。 它没有/ news /,它在{R:1}中可用,并且不包含-300×198。 不考虑图像大小,这将照顾根:

 <rule name="WordPress Rule 2" stopProcessing="true"> <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" /> <action type="Rewrite" url="{R:1}wp-includes/ms-files.php?file={R:2}" appendQueryString="false" /> </rule> 

对于图片大小,如果您可以编辑您的原始链接,那将是理想的,否则您的匹配url将只需要拉出.jpg,并在动作中添加图片大小加上.jpg特别。

解决这个问题的三个很好的select是:

  • 失败的请求追踪,它将在规则的path之前和之后显示
  • IIS日志将显示尝试的path。 例如,这应该显示“wp-includes / ms-files.php?file = 2011/04 / online-education.jpg”
  • 来自www.sysinternals.com的Procmon将显示它试图在磁盘上访问的path。