urlrewritingnet - rewrite URL with subdomain

435 Views Asked by At

I have umbraco website setting on an IIS 7 server: WWW.SITE.COM

I would like rewrite the URL WWW.SITE.COM/SIGUNP to WWW.SIGNUP.SITE.COM

is it possible by using urlrewritingnet or should I configure this by using DNS Host?

2

There are 2 best solutions below

0
Eric Herlitz On

I would use HTTP Redirect in IIS to achieve this. I'd recommend using permanent (301) as response status, this will also force most search robots to update their indexes.

Add everything inside the configuration elements to your web.config file

<?xml version="1.0"?>
<configuration>
    <location path="signup">
        <system.webServer>
            <httpRedirect enabled="true" destination="http://www.signup.site.com" exactDestination="false" httpResponseStatus="Permanent" />
        </system.webServer>
    </location>
</configuration>
0
Digbyswift On

There are several approaches to doing this and Eric's approach is a perfectly valid one. You can also use UrlRewriting.Net as you suggest but I think Eric has suggested the baked in <httpRedirect /> approach as it can be configured in the web.config and therefore also in IIS7 manually.

The disadvantages to this approach however are that:

  • It needs a developer to update the web.config; or
  • Someone with access to IIS to change the configuration
  • It requires an application restart to pick up the redirect rules

There are two other approaches you should consider:

  • A HttpModule that uses a CSV file containing a cached list of 'from' and 'to' URLs;
  • A Umbraco-managed doc type that can handle specific path redirects.

The HttpModule approach obviously requires a little coding but is very rewarding. Your SEO team/client can provide a list of URLs that need redirecting and your HttpModule can cache the list (using the file as a dependency) and perform the redirects based upon matched URLs. Any update to the file simply clears the cache automatically.

For basic redirects, I like the approach of having a "Redirect" doc type in Umbraco. This doc type will have two fields, a "redirect type" field (301/302) and a "redirect to" field. In the template for this doc type you will need a little cpde that performs a redirect to the "redirect to" node. Any hits on a page created using this doc type will automatically redirect to the target page. You can also use this doc type in conjunction with "umbracoUrlAlias" field. You can add multiple paths to this field separated by a comma (see this article for an explaination). This way you can catch multiple simliar paths and redirect to a single path.

The advantage of this approach is that it is manageable in the CMS, but the disadvantage is that the redirects are not managed centrally like a CSV file, so you need to be careful in how it is implemented.