2

I am trying to have a static HTML site rendered off the host name of our Sitecore site, such as mysite.com/_demo/index.html. All of this site is stored on the file system and is not part of Sitecore. I am trying to add this to a patch file Sitecore but I am still unable to render the site.

<site name="DEMO" patch:before="site[@name='website']" inherits="website" physicalFolder="/_demo"
        startItem="/" hostName="www-dev.mysite.com/_demo" virtualFolder="/" rootPath="/" />
3
  • 2
    Sitecore cannot serve a static HTML site. The bigger question is, why would you want it to?
    – Mark Cassidy
    Commented Jul 11, 2019 at 12:35
  • This is a demo page for Sales. We are doing a direct data migration during our upgrade to 9.1 and am trying to get the site view-able. It is currently setup as a physical folder under the IIS site.
    – Nathan S
    Commented Jul 11, 2019 at 12:47
  • You will have to do this in IIS and completely ignore Sitecore.
    – Chris Auer
    Commented Jul 11, 2019 at 13:44

1 Answer 1

3

Sitecore will serve static files directly from disk if they exist, you do not need to patch in an additional <site> if the hostName already matches another existing site you might be hosting, i.e. if www-dev.mysite.com is your main site and you just need to put some files into a subfolder then there is nothing more to do, put the files there and request the URL.

If you need a <sites> definition for some reason, then you can patch it like so:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <sites>

      <site name="DEMO"
            patch:before="site[@name='website']"
            inherits="website"
            virtualFolder="/_demo"
            physicalFolder="/_demo"
            hostName="www-dev.mysite.com" /> 

    </sites>
  </sitecore>
</configuration>

Note the use of the virtual folder to match the incoming URL:

virtualFolder: The prefix to match for incoming URL's. This value will be removed from the URL and the remainder will be treated as the item path.

The Sitecore.Pipelines.HttpRequest.FileResolver processor in the httpRequestBegin makes a check for a physical file of the requested URL, and if so allows execution of that file directly. Note that you must request the files directly, using the full URL including the extension of the file. If a directory is requested (i.e. an extensionless URL) then Sitecore also makes a check for the existence of /<directory>/default.aspx in the folder.

You can read more about this processor here and a little more about overriding that here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.