sitecoresitecore8.2sitecore-habitat

Incorrect URLs in Sitecore Habitat


After a number of trials, I finally managed to setup Habitat for Sitecore 8.2

The instance name used is habitatdev. I followed the git document on configuring these custom names in 3 config files in the VS solution.

The home page http://habitatdev works fine. But when trying to browse to any other page (say "About"), it goes to http://habitat.habitatdev/about.

This is with all other pages. I see there are redirection modules and solutions to create a new layout for redirections.

Is there any simple fix like a property in web.config where we can set the Items to navigate to http://habitatdev/[name] instead of http://habitat.habitatdev/[name]

FIX:
Open this config - \Website\App_Config\Include\Project\Habitat.Website.config

Look for the site and cacheSizes properties.

Original:

<sites>
      <site name="habitatdev" patch:after="site[@name='modules_website']"   
   targetHostName="habitat.$(rootHostName)" database="web" virtualFolder="/" .... />
    </sites>
    <cacheSizes>
      <sites>
        <habitat>
          <html>50MB</html>
          <registry>0</registry>
          <viewState>0</viewState>
          <xsl>25MB</xsl>
        </habitat>
      </sites>
    </cacheSizes>

Changed to:

<sites>
          <site name="habitatdev" patch:after="site[@name='modules_website']"   
       targetHostName="$(rootHostName)" database="web" virtualFolder="/" .... />
        </sites>
        <cacheSizes>
          <sites>
            <habitatdev>
              <html>50MB</html>
              <registry>0</registry>
              <viewState>0</viewState>
              <xsl>25MB</xsl>
            </habitatdev>
          </sites>
        </cacheSizes>

Solution

  • The problem (looking at your comment) is in your site config.

    You have:

    <site name="habitat" targetHostName="habitat.habitatdev" database="web" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/habitat" startItem="/Home" ... />
    

    which means that when Sitecore generates url, it creates them using targetHostName="habitat.habitatdev" for their host names.

    Just change it to

    <site name="habitat" targetHostName="habitatdev" database="web" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/habitat" startItem="/Home" ... />
    

    and all the urls will be http://habitatdev/...