skip to Main Content

We recently went through a major site redesign for an IIS 8, C# web site.
We have around 2 to 3 hundred old pages which needs to be redirected to new pages. All of them needs to be 301 redirects for SEO.

We are looking for some best practices to do this, without maintaining the physical files on the server.

2

Answers


  1. Maintain a database of those URLS, that can be eventually loaded into memory at startup.

    The 404 handler checks if the page exists in that database, and performs the redirect.

    I don’t know any solution for this… In sitecore or Umbraco there are some plugins to do this by example.

    But it works great… If the old URL is replaced, then it will not be handled.

    And you could extend that system even later, to maintain a database of all the urls invoked on your website … Array of References (For Each Path Item): Url + Current URl, if for some reason you rename an item, then you can update your database with all URLS that contain some item.

    Login or Signup to reply.
  2. IIS and .Net have several ways to do redirects.

    In the code handing the request:

    this.Response.RedirectPermanent("http://www.website.com/new-page/");
    

    In the web.config file (probably the easiest way for you):

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="301 Redirect 1" stopProcessing="true">
              <match url="^old-page.htm$" />
              <action type="Redirect" url="new-page" redirectType="Permanent" />
            </rule>
            <rule name="301 Redirect 2" stopProcessing="true">
              <match url="^old-page2.htm$" />
              <action type="Redirect" url="new-page2" redirectType="Permanent" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration> 
    

    It accepts regex so you can optimism this if the redirects have a pattern.

    Finally you can take full control at a base level via the Routing Module (System.Web.Routing.UrlRoutingModule) and your own IRouteHandler.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search