Is it possible to set up a Page Not Found for a microsite within the main site?

Lambert Chan asked on July 3, 2019 19:20

I'm looking at the Page Not Found settings available in Kentico and I see the option of having a specific page for the main site itself eg. www.mainsite.com

It is possible however for a microsite within the main site, eg. www.mainsite.com/microsite to have its own custom page not found? So that when someone is trying to go to www.mainsite.com/microsite/ohme they will redirect to www.mainsite.com/microsite/pagenotfound as opposed to www.mainsite.com/pagenotfound?

Correct Answer

Peter Mogilnitski answered on July 3, 2019 19:44

When you say microsite - it is not a real site in kentico? it is more like subsection of your site and for this sub section you want to have a custom 404. I guess you can chekk within your real 404 page if the 404 error belong to your micro site and do Server.Transer to microsite 404. The other way is try to set it up at the IIS level, but you microsite is purely virtual - it exists only in the Kentico tree. here is more on custom 404

1 votesVote for this answer Unmark Correct answer

Recent Answers


Lambert Chan answered on July 4, 2019 18:42

Yup, when I mean microsite I mean a subsection of the the site. So what you're recommending is that I setup a check to see if the error 404 is from www.mainsite.com/microsite as a base url and redirect it to www.mainsite.com/microsite/pagenotfound instead? Where could I setup that check?

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on July 4, 2019 19:23

Yes. You can set it up inside your main 404 page.

0 votesVote for this answer Mark as a Correct answer

Lambert Chan answered on July 4, 2019 20:18 (last edited on December 10, 2019 02:31)

So I've attempted to add this javascript to the navigation page to check for the attempted href but the page isn't reloading even though the check is true (I've tested it with window.open instead and it did open google!) Is there anything wrong in this code?

var current = window.location.href; 
var s = current.split("https://www.mainsite.org/");  
if (s[1].includes("microsite")) {window.location.replace("https://www.google.ca"); }

Edit: I figured out another way to use macros in URL redirection instead of javascript.

{% Contains(CurrentDocument.NodeAliasPath, "/microsite/") ? "/microsite/pagenotfound" : "/SpecialPages/PageNotFound" |(identity)GlobalAdministrator%}
0 votesVote for this answer Mark as a Correct answer

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