我已将此代码添加到我的wordpress网站的web.config
中:
<rule name="Redirect to WWW site">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>
这完全适用于重定向,如主页,默认wordpress url(login.php,wp-admin)。示例:
但这在我安装wordpress后创建的wordpress自定义页面中不起作用。例如:
我已按照here.的说明进行操作 我怎么解决这个问题请帮助我。
答案 0 :(得分:0)
我能够在我的网站上重现您的问题。要解决此问题,您需要在Rewrite to index.php
文件中的web.config
规则之前移动您在上面发布的代码,如下所示。并且在测试时不要忘记清除Web浏览器的缓存。
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to WWW site">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Rewrite to index.php" patternSyntax="Wildcard">
<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" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>