Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » URI

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 2256 Views
  • KatB
    Avatar
    Community Member
    94 Posts

    URI Link to this post

    I have a pre-existing URI site structure that I would prefer to keep. It would be so much easier to keep it.

    The alternative is to create a new line in my .htaccess for each page that I am replacing. That will end with a huge .htaccess file, and surely, a performance hit.

    What would the Silverstripe team recommend?

  • Tim
    Avatar
    Core Development Team
    201 Posts

    Re: URI Link to this post

    There is away of remapping legacy URL's... I'll get one of the devs to post some info on this.

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: URI Link to this post

    subscribe

  • KatB
    Avatar
    Community Member
    94 Posts

    Re: URI Link to this post

    to what?

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: URI Link to this post

    I believe he meant he is subscribing to the topic so he can track the updates.

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: URI Link to this post

    Yeah, sorry... My bad... should've been more clear..

  • Andy
    Avatar
    230 Posts

    Re: URI Link to this post

    There is a 'redirector' page type that you can use to redirect pages, unfortunately this doesn't support multi level URLs (like news/article-one). The other method that I've used to solve this in the past is to check for the second level URL in the init function like this:

       function init() {
          if($this->urlParams['Action']) {
             $oldurl = Convert::raw2sql($this->urlParams['Action']);
             $page = DataObject::get_one('SiteTree', "REPLACE(URLSegment, '-', '')='$oldurl'");
             if($page) {
                Director::redirect($page->Link());
                Page_Controller::init();
                return;
             }
          }
          
          parent::init();
       }

    2256 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.