Alternative URL pointing to a PDF file: "Target path must not be a view"

My new Plone 5.2 site is supposed to replace an old CPS site and I want to have at least some URLs of the old site to be the alternatives of their counterparts of the new one. More precisely:

  • the old site contained some PDF files that could be downloaded directly from their URL, e.g.:
    .../members/dbitouze/pub/latex/diapositives-cours-d/conference-n-1/downloadFile/file/en-ligne1.pdf
  • the same file can now be downloaded directly from:
    .../Members/d--bitouze/pub/latex/diapositives-cours-d/conference-n-1/@@download/file/en-ligne1.pdf

The problem is when I try to add the former as an alternative of the latter (on .../@@redirection-controlpanel), Plone returns the error:

Target path must not be a view

How could I add an alternative URL pointing to a PDF file?

Moreover, if the old URL:

.../members/dbitouze/pub/latex/diapositives-cours-d/conference-n-1/downloadFile/file/en-ligne1.pdf

is an alternative of:

.../Members/d--bitouze/pub/latex/diapositives-cours-d/conference-n-1

instead of:

.../Members/d--bitouze/pub/latex/diapositives-cours-d/conference-n-1/@@download/file/en-ligne1.pdf

(view part /@@download/... dropped), it works, but oddly: the file is downloaded, not as en-ligne1.pdf, but as conference-n-1 which is nevertheless this en-ligne1.pdf file and considered (at least by Firefox) as a PDF file (it is open with my default PDF viewer).

The error message indicates that the function may want to redirect to an object and not an object's view. The @@ it typically used to indicate a view (in your case in the @@download).

I already understood this :wink: but the question remains: is it possible to add an alternative URL that loads the PDF file under its own name?

I do not know.

In older Plone versions, it was possible to configure (via portal_types) how object urls (with default method alias) should be handled and for files and images this was by default a kind of download. I am not sure whether this is still possible in Plone 5 and whether you would be ready to go this route.

Almost surely, it is possible to remove the requirement "Target path must not be a view" BUT it will likely require changing or extending code. Apparently, out of the box, you cannot have a view in the url to redirect to.

You may be able to use configuration in your web server to perform the redirects.