Link to home
Start Free TrialLog in
Avatar of vituxa
vituxa

asked on

How do I make IIS respond with 301 instead of 404?

Hi Experts.
Is there a way I can make IIS respond with 301 instead of 404?

I have this domain name that used to be a very powerful website. No matter what link is clicked I need to 301 it to somewhere else.

I set up a default.aspx file that has this code in it:

protected void Page_Load(object sender, EventArgs e)
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location", "http://www.sitetoredirectto.com");
    }
}

Open in new window


but that only catches it for a main domain name. So if someone goes to www.thisnewdomainigot.com it works, but if someone goes to www.thisnewdomainigot.com/whateverlinkthisis.html it doesn't and still 404s.
I need to make Google think there isn't any 404s. How can I do that ?

Please help.
ASKER CERTIFIED SOLUTION
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vituxa
vituxa

ASKER

I found out another way to do this: I've added this in system.webServer tag in Web.Config:

<rewrite>
        <rules>         
          <rule name="Anything" stopProcessing="true">
            <match url="(.*)$" ignoreCase="true" />
            <action type="Redirect" url="http://www.thesiteimredirectingTO.com" redirectType="Permanent" />
          </rule>
       </rules>
</rewrite>

Open in new window

Avatar of vituxa

ASKER

but you did help me - Thank you.