Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Custom URL Structure: redirect parent, but not children

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1693 Views
  • golian
    Avatar
    Community Member
    2 Posts

    Custom URL Structure: redirect parent, but not children Link to this post

    Hi there,

    i'm pretty new to SilverStripe and need some help with custom URLs.

    I have the following structure:

    • mypage.com/..
    • mypage.com/section1/..
    • mypage.com/section2/pagesOf2

    now i'd like to create the following "behaviour":

    1: if the user tries to visit "section2" directly ("mypage.com/section2") and no specific page,I
    he should see "section1" ("mypage.com/section1").

    2: otherwise - if he calls a specific page of "section2" ("mypage.com/section2/aPageOf2") - there should be no redirect and he gets to the page

    What am i looking for?

    1. Some conceptual help: What would you use to create such behaviour and why: A custom controller class? a rule in _config ? Some function in the section2_controller class?

    2. Some practical help: I'd be glad to get a code snippet from you, since php coding is not my main skill.

    sincerely,
    golian

  • Yasen
    Avatar
    Community Member
    4 Posts
  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Custom URL Structure: redirect parent, but not children Link to this post

    There's no need to implement any custom controller code for this - just set up the parent Section 1 page as a RedirectorPage which redirects users to Section 2, and then add children like normal under it.

  • golian
    Avatar
    Community Member
    2 Posts

    Re: Custom URL Structure: redirect parent, but not children Link to this post

    Thanks for your help.

    @Yasen : indeed there are some useful information for me!

    @ajshort well, in my case "section2" is "blogHolder-page" - so i cant change it to type "redirector-page"

    1693 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.