Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

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

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

permanent redirections


Reply


3 Posts   1500 Views

Avatar
Nicolaas

Forum Moderator, 213 Posts

30 May 2007 at 10:03am

Edited: 30/05/2007 11:24am

Hi Folk

I am rebuilding a site from straight html to a silverstripe application. I would like to setup automatic redirects for the old pages. In the database, I noticed the legacyUrl field. How can I use that? There are 137 pages so a "global" solution would be best.

Any help much appreciated.

Cheers

Nicolaas

Avatar
Sam

Administrator, 685 Posts

2 June 2007 at 6:21pm

I think that the LegacyURL field is something for a specific site that accidentally got put into the main codebase! :-P

Are the old URLs in any consistent format? Your two basic solutions are setting up RedirectorPage pages with the old URLs, if the are of the form http://www.mysite.com/(url)/

If they are mostly in a couple of directories, you could set up director rules that point to a custom controller that does the redirection.

For example, if you have a bunch URLs of the form http://www.mysite.com/products/(XXX).html,

you could set up a director rule

'products/$ProductURL' => 'ProductRedirector'

and then make a class

class ProductRedirector extends Controller {
function index() {
// do something with $this->urlParams['ProductURL'];
}
}

Avatar
Nicolaas

Forum Moderator, 213 Posts

5 June 2007 at 10:40am

Hi Sam

thank you for your reply. you should keep the legacyUrl, it is USEFUL!

Anyway, this is how I did it (dirtiest hack of the month):

http://www.silverstripe.com/general-discussion/flat/1361#post1361