Redirect alias to a DNN site

Overview

In this article, you will learn to redirect a domain to a DNN site or page. 

Step-By-Step Guide

Before moving on to the step by step, bear in mind that we will use these two keywords during the explanation: 

  • yourdomain.com = Domain URL that you want to redirect
  • dnnxxyyzz = DNN domain 
  1. Determine which records you need to create in your domain name registrar or DNS provider (Depending on where you have your source domain you will need to make the changes in one or the other)
  2. Confirm that your DNS entries from Step 1 have propagated correctly using a tool such as  https://dnschecker.org/


  3. Go to OnDemand > Manage Account > On Demand Installations > DNS Management
  4. Enter each subdomain/domain name combination in the list on the DNS Management page
    As you add domain names, the system will verify that the CNAME records have been configured correctly
  5. Click on Save DNS Changes
  6. Go to the site’s folder where the site is installed
  7. Open the web.config file with your preferred text editor.
  8. Locate the rewrite node by searching the <rewrite>, it should be in its own section inside the system.webserver node
    • If you don’t find it, add it along with a rules node above the following line:
      </system.webServer> 
    • Example:
      <rewrite>
      <rules>
      </rules>
      </rewrite>
      </system.webServer> 
  9. Add the following rule inside the rewrite node, which should handle all the redirections from the newly added domains to the site
    <rule name="Your Rule Name here" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAny">
    <add input="{HTTP_HOST}" pattern="(subdomain|m).yourdomain.com" />
    <add input="{HTTP_HOST}" pattern="yourdomain2.com" />
    <add input="{HTTP_HOST}" pattern="yourdomain3.com" />
    </conditions>
    <action type="Redirect" url="https://www.dnnxxyyzz.com" redirectType="Permanent" />
    </rule>
  10. In the same web.config file, after the rule you added to redirect the domains or instead of it should you not need those domains redirected, add the following rule(s) for redirecting a domain to a specific page in your DNN site. 
    <rule name="Your page redirect rule name" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="yourdomain4.com" />
    </conditions>
    <action type="Redirect" url="https://www.dnnxxyyzz.com/Pages/PageOne" redirectType="Permanent" />
    </rule>
    Note: Each redirect should have its own rule since they each redirect to a different page

    In summary, the first part of the rule catches every request (.*) and then checks whether the request matches that the condition is met. If it's met, it applies the action configured. 

    For this example, If the request matches this condition (pattern="yourdomain4.com") then the action is a permanent redirect to the PageOne in your site over HTTS.

 

Comments

0 comments

Please sign in to leave a comment.