Setting domain names for sites

The Domain name is one of the basic properties that you assign when creating new sites. The system generates the URLs of the website’s pages and other components using the specified domain name.

Every website running in the system must have a unique domain name. If necessary, sites can share the same basic domain name, but the values cannot be completely identical (for example, the difference can be in the virtual directory or URL path component).

To set the main domain name for an existing website:

  1. Open the Sites application.
  2. Edit () the site.
  3. Type the domain into the Site domain name property on the General tab.
  4. Click Save.

Domain name format

Enter the domain name without the http:// protocol and www prefix. Include the port number if it is different than 80.

Correct:

  • mycompany.com
  • partners.mycompany.com
  • mycompany.com:8080

Incorrect:

  • http://mycompany.com
  • www.mycompany.com

Adding domain aliases

Domain aliases are alternative domain names that lead to the same website. You can add any number of domain aliases for each site. For example, if your website uses mycompany.com as its main domain and you also wish to assign the my-company.co.uk domain to the same website, you need to create a domain alias. Aliases can be particularly useful when building multilingual websites.

To create a domain alias for your website:

Note: You need to have a valid license for every domain alias. Domain alias licenses are free of charge if you already own a license for the main domain.

  1. Open the Sites application.

  2. Edit () your site.

  3. Select the Domain aliases tab.

  4. Click New domain alias.

  5. Type the alternative domain name into the Domain alias property.

    • Use the same format as for the site’s main domain name, without the protocol or www prefix.
  6. (Optional) Set the Default alias path.

    • Specifies the default page that the system displays when users access the site’s root URL through the domain alias.
    • Overrides the Settings -> Content -> Default alias path setting.
  7. Click Save.

The site is now available under the alias’s domain name.

Domain names for local development

When running or debugging your website locally during development (for example using the built-in web server in Visual Studio), you need to use the domain names assigned to your site in Kentico.

  • You can adjust the Project URL of your project accordingly in your development environment (Visual Studio).
  • If you wish to run on a localhost domain, but your site has a different domain name assigned, you need to add localhost as a domain alias.

Redirecting aliases to the main domain

You can configure domain aliases to automatically redirect users to another URL. When a visitor accesses the website through the domain alias, the system sends them to the specified URL instead.

If the only purpose of your domain aliases is to make the site available under multiple domain names, it is recommended to redirect the aliases to the website’s main domain. This is a common Search engine optimization practice that prevents duplicate web content (i.e. having multiple URLs leading to the same content).

To set up redirection for your domain aliases:

Configure the redirect URL

  1. Open the Sites application.

  2. Edit () your site.

  3. Select the Domain aliases tab.

  4. Edit your aliases.

  5. Type the target URL into the Redirect URL property.

    The Redirect URL property supports only absolute URLs. Use macro expressions to dynamically redirect users to the correct page, for example: {%protocol%}://domain.com{%relativepath%}.

    • {% protocol %} - resolves into the current URL scheme name (protocol) when the redirection takes place
    • {% relativepath %} - resolves into the current relative URL path when the redirection takes place
  6. Click Save.

(Optional) Configure output caching for the domain variable

If you are using a Default alias path for any of the domain aliases, you need to make the output cache store different data based on the different domains.

  1. Open the Settings application.
  2. Go to System -> Performance.
  3. Under Output caching, enable Output cache variables - domain.
  4. Save.

The system now automatically redirects all users to the site’s main domain. For example, if your site’s main domain is domain.com and you have domain.co.uk as a domain alias, users who access https://domain.co.uk/example.aspx are redirected to https://domain.com/example.aspx.

Setting the domain for content only sites

If your site is a content only site (i.e., a site created using the MVC Blank Site template), you can set a URL leading to the live site’s domain. This is useful for preview feature when developing MVC sites.

  1. Open the Sites application.

  2. Edit () your site.

  3. On the General tab, type the URL leading to the site’s domain into thePresentation URL property. For example:

    http://www.mysite.com

  4. Save.

Note: You need to have a valid license for the domain in the Presentation URL.

Links on the live site will now be resolved with the domain you entered. Notethat Kentico can’t guarantee that links used (clicked on) directly on the Pagetab of the Pagesapplication will resolve correctly when using this property.