Jump to:

325 Posts in 200 Topics by 157 members

Migrating a Site to Silverstripe

SilverStripe Forums » Migrating a Site to Silverstripe » Preserving existing link structure

What you need to know when migrating your existing site to SilverStripe.

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

Page: 1
Go to End
Author Topic: 2615 Views
  • chris_d
    Avatar
    Community Member
    21 Posts

    Preserving existing link structure Link to this post

    Hi there,
    I've currently got a site with page such as domain.com/example.htm

    I would like move the site into silverstripe, but keep the existing addresses.

    For seo reasons, I dont want to just use mod_rewrite to rewrite addresses.

    Ie I want to be able to go to domain.com/example.htm and load an actualy silverstripe page, then be able to link to domain.com/example.htm from other pages and menus.

    So basically what Im asking is how can I get silverstripe to allow dots in filenames?
    I've ripped out some of the code so it won't give me an error message when I try to use dots, but the dots are still being rewritten to dashes somewhere.

    Thanks for any help,
    Chris

  • chris_d
    Avatar
    Community Member
    21 Posts

    Re: Preserving existing link structure Link to this post

    this was a bit of a bitch to get working so thought i'd post what i did to get this working in the end:

    I used the nestedurls build and changed in SiteTree.php

          // Keep it clean
          } else if(isset($this->changed['URLSegment']) && $this->changed['URLSegment']) {
             $segment = ereg_replace('[^A-Za-z0-9]+','-',$this->URLSegment);

             $segment = ereg_replace('-+','-',$segment);

    to

          // Keep it clean
          } else if(isset($this->changed['URLSegment']) && $this->changed['URLSegment']) {
             $segment = ereg_replace('[^A-Za-z0-9]+','-',$this->URLSegment);

             $segment = ereg_replace('-+','-',$segment);
    //hack
    $segment= str_replace("-htm",".htm", $segment);

    also to get rid of trailing slashes:
       public function Link($action = null) {
    $linkwithslash = Controller::join_links(Director::baseURL(), $this->RelativeLink($action));
    if ('/' == substr($linkwithslash, strlen($linkwithslash)-1)) $linkwithslash = substr_replace($linkwithslash, '', strlen($linkwithslash)-1); // strip trailing slash

    return $linkwithslash;   
    //   return Controller::join_links(Director::baseURL(), $this->RelativeLink($action));
       }
       

    Clearly there is a reason why the developers have chosen not to have this in by default (security?) so I'll have a look to see if I can tidy this up and post back later.
    This trick could also be used to allow foreign letters in rusl etc.

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: Preserving existing link structure Link to this post

    Thats really cool, I'd prefer to append file names to URL's . It'd be interesting to find out if it is a security issue, it could just a usability issue.

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