Redirect internal links to another files

The Basics

  • Nextcloud Server version (e.g., 29.0.5):
    • 30.0.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 22.04
  • Web server and version (e.g, Apache 2.4.25):
    • Apache
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • Haproxy
  • PHP version (e.g, 8.3):
    • 8.1
  • Is this the first time you’ve seen this error? (Yes / No):
    • No
  • When did this problem seem to first start?
    • After storage change
  • Installation method (e.g. AIO, NCP, Bare Metal/Archive, etc.)
    • Bare Metal
  • Are you using Cloudflare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

Hello!
As a result of an incorrect storage change (no change was made in the DB in the ‘oc_storages’ table), records of all files in the DB were duplicated as new ones on the new storage.
At the same time, all old internal links stopped working. I can’t roll back to the backup, since a lot of changes were made on the new storage.
As a good solution, it seems to me possible to make a redirect when accessing old links. I can extract the [old_file_id=>new_file_id] match from the DB. Is it possible to make a redirect to https://cloud.tld/f/new_file_id when accessing the link https://cloud.tld/f/old_file_id?
It looks possible in three lines of code, but please help me understand - will this work and in which file is the processing of opened URLs performed?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.