【发布时间】:2019-04-16 08:44:36
【问题描述】:
我正在尝试让网络重定向为我的 wordpress 网站工作,但重定向 url 没有任何反应。
该网站是 wordpress 并且有一个现有的 web.config 文件,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress" 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>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
我希望 url 重定向 FROM /path/to/old TO /path/to/new 并在第一条规则之后添加以下内容:
<rule name="Redirect" stopProcessing="true">
<match url="^path/to/new" />
<action type="Redirect" url="http:/www.site.com/path/to/new" redirectType="Found"/>
</rule>
所以完整的代码如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress" 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>
<rule name="Redirect" stopProcessing="true">
<match url="^path/to/new" />
<action type="Redirect" url="http:/www.site.com/path/to/new" redirectType="Found"/>
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
我是 web.config 的新手,但之前使用过 .htaccess。这里有点不知道为什么它不起作用 - 当我输入应该重定向的 URL 时,网站上什么也没有发生。
【问题讨论】:
标签: xml apache azure url web-config