On our umbraco site we have a page that uses child nodes to dynamicaly fill the page, using RenderTemplate() with the children node Id's. It is now possible to visit these nodes directly, but we want to prevent this. What would be the best way to go about this? Thanks in advance.
You could use the URL rewrite module to redirect to the parent page if you have a pattern you can match on the URLs... Or have a macro/in line logic based on some boolean document parameter on your child pages to redirect to parent if the child page is hit?
I created a short URL check that redirects back to the parent node in case the Request.Url is the same as the URL of the node itself.
Uri umbracoUrl = new Uri(umbraco.library.NiceUrlWithDomain(CurrentPage.Id)).TrimPathEndSlash();
Uri requestUrl = Request.Url.TrimPathEndSlash();
if (Uri.Equals(requestUrl, umbracoUrl))
{
Response.RedirectPermanent(CurrentPage.Parent.Url);
}
This seems to work perfectly. I am not sure if this will work in all cases, but for now I am satisfied.
Forbid direct url access to child nodes
On our umbraco site we have a page that uses child nodes to dynamicaly fill the page, using RenderTemplate() with the children node Id's. It is now possible to visit these nodes directly, but we want to prevent this. What would be the best way to go about this? Thanks in advance.
You could use the URL rewrite module to redirect to the parent page if you have a pattern you can match on the URLs... Or have a macro/in line logic based on some boolean document parameter on your child pages to redirect to parent if the child page is hit?
Hi Roald
Another approach could be to set a different template for the child nodes, and let that template redirect to the parent page.
If it's just one level up you can do something like:
Cheers,
Allan
Thank you for the answers!
I created a short URL check that redirects back to the parent node in case the Request.Url is the same as the URL of the node itself.
This seems to work perfectly. I am not sure if this will work in all cases, but for now I am satisfied.
is working on a reply...