简体   繁体   中英

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

to this:

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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