简体   繁体   中英

301 Redirect from web.config on IIS 6

I need to make an 301 Redirect from the web.config on a IIS 6 server (Windows 2003 Web Server). I'm a Apache-server guy, and do not have a clue about Windows Web Servers. I only have access to the server from FTP.

I have found the following in another question, but it does'nt seem to work:

<system.webServer>
    <rewrite>
        <rules>
        <rule name="Redirect to WWW" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^mydomain1.com$" />
          </conditions>
          <action type="Redirect" url="http://www.mydomain2.com"
               redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
</system.webServer>

I need to redirect seperate pages from mydomain1.com to mydomain2.com .
Ex. mydomain1.com/somename should redirect to mydomain.com/someothername

How can this be done?

---- Edit ----
After seeing another thread here on stackoverflow, my configuration now kind of looks like this:

<system.webServer>
    <rewrite>
        <rule name="rule1">
            <match url="default.aspx"/>
            <action type="Redirect" redirectType="Permanent" url="http://www.mydomain.com/somename/somename.aspx"/>
        </rule>
        <rule name="rule2">
            <match url="somename.aspx"/>
            <action type="Redirect" redirectType="Permanent" url="http://www.mydomain2.com/somename2/somename2.aspx"/>
        </rule>
    </rewrite>
</system.webserver><br>

--- Edit 2 ---- Code for redirecting the root:

As far as I investigated, There is no way to redirect by web.config on IIS6.

rewrite and httpRedirect directives can use only same or after IIS7.

But you can use ISAP way with paid solution .

So, I think Response.Redirect("direct to"); is best way

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