2
votes

We have multiple sites running in the same Sitecore instance. All of the sites have the same starting item and item tree, because the content on each site is mostly identical.

There are some pages which should appear in some sites but not in others. I would like to be able to configure an item such that it only exists in site A, and if a user tries to access it on site B then they receive a 404 error. Does Sitecore have a built in way of achieving this?

My current idea consists of adding a property 'Sites to appear on' to the page template, and then adding a custom pipeline processor which checks this value for the current page and then either returns the page or a 404 error.

1
Nothing out of the box to do this, your approach is the one I would take as well, but depending of how many of these pages you have, you might want to do it the other way round - Do not show on sitesjammykam
What about setting user domain for that restricted site like <site name="sitea" domain="sitea" and removing read access rights for sitea/anonymous user? But then I still some custom code for returning 404 will have to be written. Benefit is, you can use inheritance and block whole http://sitea/section/*** pages with single click in security editor.Marek Musielak
Does each site has its own language?Hishaam Namooya
That's actually a very good idea @MarekMusielak +1jammykam

1 Answers

0
votes

My current idea consists of adding a property 'Sites to appear on' to the page template, and then adding a custom pipeline processor which checks this value for the current page and then either returns the page or a 404 error.

This is actually the best approach you can offer! Just add a multilist field to an item template to pick an allowed site, add a custom attribute to the site definition in the site config (e.g. siteId={id}).

After that you can easily compare those values in site resolver.

Please keep in mind that you should also override a link manager to make sure your links are generated properly