269 Posts in 63 Topics by 127 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, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 2374 Views |
-
Preserving existing link structure

20 December 2008 at 4:12am
Hi there,
I've currently got a site with page such as domain.com/example.htmI 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 -
Re: Preserving existing link structure

20 December 2008 at 5:00am Last edited: 20 December 2008 6:13am
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 slashreturn $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. -
Re: Preserving existing link structure

9 July 2009 at 5:01pm
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.
| 2374 Views | ||
|
Page:
1
|
Go to Top |


