1

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:

Crave
  • 175
  • 3
  • 14
  • You'd need http://www.iis.net/downloads/microsoft/url-rewrite installed to get that to work. Is it? – Daniel Morritt Feb 21 '13 at 13:20
  • I'll check up on that. I need to contact the hosting support. Their support could not help me with the answers to my questions either, so i hope they can answer this one. – Crave Feb 21 '13 at 15:26
  • Okay, the site is now moved to another server with IIS8 and url-rewrite installed. I have tried the above code again, but all i get is an error: "HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid." – Crave Feb 22 '13 at 11:06
  • Seen this error, you'll get that if URL Rewrite not installed. To test, try removing the whole rewrite segment, should work fine, put it in, it'll fall over. – Daniel Morritt Feb 22 '13 at 14:54
  • Thanks Daniel. I contacted the support again and explained the situation. They asked me to upload the web.config file again, so they could look at it. And suddently it works. – Crave Feb 25 '13 at 13:14
  • Now my biggest problem is to redirect the mydomain.com **mydomain.com/default.aspx** is redirecting, but not the root. How can i do that? I have tried with `` but doesn't work. – Crave Feb 25 '13 at 13:27
  • I figured it out - found this [link](http://stackoverflow.com/questions/7018818/iis7-url-redirection-from-root-to-sub-directory) – Crave Feb 25 '13 at 13:33

1 Answers1

0

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

Takeo Nishioka
  • 369
  • 2
  • 11