automatic Redirection of First Child page | Community
Skip to main content
Level 2
Oct 13, 2022 5:03 AM UTC
Solved

automatic Redirection of First Child page

Hi All,

I have requirement parent page automatically redirect  to first child page which is specific template type 

How to do in Sightly  or need to do in java.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
B_Sravan
B_SravanAccepted solution
New Participant
Oct 13, 2022 7:00 AM UTC

1,2 – if it is not constant or not to be authorable, isn't that contradictory?

 

"3.it always get the first child page url ."

- Yeah, handle the logic in your java class!

3 replies

B_Sravan
New Participant
Oct 13, 2022 5:52 AM UTC

you can handle this in multiple ways.

1. Using sling framework, make use of redirect feature in the page properties – advance properties and select the page to redirect to a desired location.

 

2. Using dispatcher rewrite rules, (Note: here you need a code build in order to change the values in future). Example rewrite rule:

# Redirect rule for parents pages navigating to home page
RewriteRule "^/(product|product/|product.html|notice|notice/|notice.html|errors|errors/|errors.html|mod|mod/|mod.html|administration|administration/|administration.html|experts|experts/|experts.html|support|support/|support.html)$" / [R,L]

the above rule was written in an intension to redirect all parent level (or level 1 pages) pages, which don't have content to the home page.

3. Using sightly/Java, you can still get a list of child pages and then the redirection needs a script to work, I don't think there is much of a direct approach. Speaking of which, make use of standard HTML meta tag and feed in the values through sightly.

<html>
   <head>
      <title>HTML Meta Tag</title>
      <meta http-equiv = "refresh" content = "3; url = https://www.someabcs.com" />
   </head>
   <body>
      <p>Redirecting to another URL</p>
   </body>
</html>

in the above html, replace the url with the sightly/sling model returned first child page of your desired template.

These are the things I could think at this moment.
I hope it helps, thank you.

 

Regards,

Sravan

Translate
bangar20Author
Level 2
Oct 13, 2022 6:29 AM UTC

Hi @b_sravan ,

Thanks for reply.

1.they don't want to be authorable

2.it is not always constant to add in the rewrite rule.

3.it always get the first child page url .

Translate
B_Sravan
B_SravanAccepted solution
New Participant
Oct 13, 2022 7:00 AM UTC

1,2 – if it is not constant or not to be authorable, isn't that contradictory?

 

"3.it always get the first child page url ."

- Yeah, handle the logic in your java class!

Translate