使用 web.config 文件在 IIS 中看似简单的重定向 [英] Seemingly simple redirect in IIS using web.config file
本文介绍了使用 web.config 文件在 IIS 中看似简单的重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经重构了一个托管在 Windows 服务器上的 WordPress 站点,因此我尝试使用 web.config 文件进行重定向.我已经从示例中尝试了数十种变体,但无法使其正常工作.新网址已更改为:
I've restructured a WordPress site that's hosted on a Windows server, so I'm trying to redirect with a web.config file. I've tried dozens of variations from examples and I can't make it work. The new urls have changed from this:
www.mysite.com/wp/whatever-else
www.mysite.com/wp/whatever-else
对此:
www.mysite.com/whatever-else
www.mysite.com/whatever-else
我尝试过的一些例子包括:
Some examples I've tried include:
<rewrite>
<rules>
<rule name="WP Redirect">
<match url="^(.*)/wp/(.*)" />
<action type="Rewrite" url="{R:1}/{R:2}" />
</rule>
</rules>
</rewrite>
<小时>
<rewrite>
<rules>
<rule name="WP Redirect">
<match url="^(.*)/?wp(.*)" />
<action type="Rewrite" url="http://www.mysite.com/{R:1}" />
</rule>
</rules>
</rewrite>
<小时>
<rewrite>
<rules>
<rule name=""WP Redirect" stopProcessing="true">
<match url="^com/wp/?" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
</conditions>
<action type="Redirect" url="{R:1}/" />
</rule>
</rules>
</rewrite>
有什么建议吗?我难住了.谢谢.
Any suggestions? I'm stumped. Thanks.
推荐答案
试试这个:
<rewrite>
<rules>
<rule name="WP Redirect" stopProcessing="true">
<match url="^wp/(.*)$" ignoreCase="false" />
<action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/{R:1}" />
</rule>
</rules>
</rewrite>
这篇关于使用 web.config 文件在 IIS 中看似简单的重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文