我使用 URL Rewrite / ARR 作为反向代理来模拟 IIS 子目录中的 Wordpress 安装,该子目录实际上在远程 Apache 上运行。
它比我预期的要好,但还有一个烦人的问题:当用户发表评论时,它会被正确重定向并保存在 wp 端。但是,以下重定向没有被正确重写:
我得到的是 eghttp://domain.tld/2014/01/11/posttitle/#comment-6
而不是http://domain.tld/blog/2014/01/11/posttitle/#comment-6
.
正如我之前所说,所有其他相关链接/图像/样式表都按预期工作,并被重写为domain.tld/blog/<path>
.
Wordpress 方面的最后一个操作似乎是(在wp-comments-post.php
):
$location = apply_filters( 'comment_post_redirect', $location, $comment );
wp_safe_redirect( $location );
这是我的重写规则:
<rewrite>
<rules>
<rule name="RewriteRemoteAddr">
<match url="(.*)" />
<conditions>
<add input="{HTTP_X_FORWARDED_FOR}" pattern="([_0-9a-zA-Z]+)" />
</conditions>
<serverVariables>
<set name="{REMOTE_ADDR}" value="{HTTP_X_FORWARDED_FOR}" />
</serverVariables>
<action type="None" />
</rule>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://blog.domain.tld/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^http(s)?://blog.domain.tld/(.*)" />
<action type="Rewrite" value="http{R:1}://domain.tld/blog/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
系统:
IIS 8.5、URL 重写 2、ARR 3
Wordpress 3.8
编辑W3SVC9 日志条目:
2014-01-11 19:12:14 W3SVC9 ares 444.444.444.444 POST /blog/wp-comments-post.php X-ARR-CACHE-HIT=0&X-ARR-LOG-ID=d6339e31-547d-4f25-b1cc-5ebe2b485a1d 443 - 333.333.333.333 HTTP/1.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+rv:26.0)+Gecko/20100101+Firefox/26.0 comment_author_b9276ad9dc2bc4f28d3a0f251eafa31e=tester;+comment_author_email_b9276ad9dc2bc4f28d3a0f251eafa31e=test%40example.com;+wordpress_test_cookie=WP+Cookie+check https://domain.tld/blog/2013/12/27/posttitle/ blog.domain.tld 302 0 0 906 1283 156
2014-01-11 19:12:14 W3SVC9 ares 444.444.444.444 GET /2013/12/27/posttitle/ - 443 - 333.333.333.333 HTTP/1.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+rv:26.0)+Gecko/20100101+Firefox/26.0 comment_author_b9276ad9dc2bc4f28d3a0f251eafa31e=tester;+comment_author_email_b9276ad9dc2bc4f28d3a0f251eafa31e=test%40example.com;+wordpress_test_cookie=WP+Cookie+check https://domain.tld/blog/2013/12/27/posttitle/ domain.tld 404 0 0 6282 926 171
谢谢!