old to new page path url redirection

Will a changed page path URL redirect from old > new forever?

This is a very basic question, however I haven’t been able to find any documentation about this. When changing an existing page path url (e.g. website.com/cats to website.com/i-like-cats) I see that SilverStripe automatically redirects the old to new url. Does this redirect stay in place indefinitely, or is it wise to also setup 301 redirects?

I believe it will stay in place indefinitely (unless another page is created with the first URL).

There is an argument that says it’s better to set up a 301 redirect if it’s likely to be a page which has a lot of inbound links… that way you don’t need to load / execute all the framework code just to deal with the redirection every time. (Obviously, that’s a case-specific decision that you’ll have to take)

1 Like

The code for looking for the old URLSegment (in this case cats) lives here.

It’s code that intercepts a 404 request to redirect to a pages new URLSegment. It searches for any page that has ever had that URLSegment set and if it finds one then it will try to redirect to where that new page points.

If you’re relying on the 301 permanently then you should look to using .htaccess style redirects if it’s only a few instances and warrants a deploy. Otherwise you could use silverstripe-redirectedurls to allow content authors/admins to edit the redirects. The module works well and is resilient (we’ve been using it on a site with >100k redirects without any issues so far)

1 Like

Thanks for the info. And yes we are using the redirect urls module, which is great not having to deploy just for .htaccess redirect additions.