简体   繁体   English

使用 web.config 文件在 IIS 中看似简单的重定向

[英]Seemingly simple redirect in IIS using web.config file

I've restructured a WordPress site that's hosted on a Windows server, so I'm trying to redirect with a web.config file.我重组了一个托管在 Windows 服务器上的 WordPress 站点,因此我尝试使用 web.config 文件进行重定向。 I've tried dozens of variations from examples and I can't make it work.我已经尝试了数十种示例变体,但无法使其正常工作。 The new urls have changed from this:新的 url 已从这里更改:

www.mysite.com/wp/whatever-else www.mysite.com/wp/whatever-else

to this:对此:

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.谢谢。

Try this one:试试这个:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM