File URLs after new page order

I’ve got a client website which contains a lot of PDF files. Some of these are linked somewhere. The links to these files look like that:
http://www.website.com/content/5-page/2-subpage/15-subsubpage/filename.pdf

The client now wants to change the order of the subpage. In this example it would no longer be 2-subpage but rather 4-subpage. Unfortunately the old links won’t work then.

Can I create a route to redirect the old links to the new ones? Or is there another solution?

Why are the sorting numbers in the file url, anyway?

Thanks a lot,
Thomas

The only way to prevent this in the first place would be to use a central file folder instead of putting the files in the page folders. This would make sense if pages are likely to be reordered often by the client.

As regards the problem with old links, yes, you would have to use a route, or reroute in your .htaccess or the server conf file.

Yes, that would have been better. I thought the page order is fixed when I created the structure. :confounded:
To change this structure afterwards is almost impossible. Or at least way too much effort.

Why exactly does Kirby add the sorting number to the file paths? I know that this is the actual file path on the server. But since Kirby 2.3, the thumbs are being created in the page folders without the sorting numbers, too. Would it make sense to change this functionality in the core?

Then Kirby would have to reroute all file urls internally.

Kirby actually has a built-in route for this: http://www.website.com/page/subpage/subsubpage/filename.pdf. It is a redirection to the actual URL of the file, no matter what the sorting number is.

File URLs are not served by Kirby but by Apache directly, so the URL must match an actual file path. :slight_smile: