Run section under subdomain

Joel Dahlin asked on December 7, 2016 19:23

I have a site, site.com that I want to run /blog under blog.site.com. I am able to add a domain alias for blog.site.com that has a default alias path of /blog.

blog.site.com loads the /blog page as I hoped. However, subpages under the /blog page do not run under the subdomain as I had hoped. ie. blog.site.com/categories does not load but site.com/blog/categories does load. Is it possible to get the Default Path and all child pages to run under the subdomain?

Recent Answers


Peter M answered on December 7, 2016 21:09 (last edited on December 7, 2016 21:11)

That is correct. You just did the redirect only for the front blog page, but you didn't redirect all the other blog pages. Kentico doesn't know about domains, Kentico cares about paths : site.com/mypath and blog.site.com/mypath are equal but they are not equal for site.com/blog/mypath. You either need to add a new alias to existing blog pages so your category page will work with 2 URLs: /categories and /blog/categories (You probably need to pick the main URL and set alias redirect to main URL to avoid duplication). Or sometimes I create a backward compatibility page (with a custom web part) where I capture all old URLs and 301 redirect them to the new ones.

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on December 8, 2016 06:01

Hi Joel,

You can create rewrite rules which will rewrite all request from blog.site.com to site.com/blog/. You can do it in web.config file, example:

<rule name="Rewrite Example">
  <match url="(.*)" />
  <conditions trackAllCaptures="true">
   <add input="{CACHE_URL}" pattern="^(.+)://" />
   <add input="{HTTP_HOST}" pattern="^blog.site.com$" />
  </conditions>
  <action type="Rewrite" url="{C:1}://site.com/blog/{R:1}" />
</rule>

or there are some Kentico modules for this purpose:
- Custom 301 Redirect Module
- Custom Redirects Module

Article about URL redirection

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.