Closed CreateSean closed 10 months ago
client has asked about this again? Is there something we're doing incorrectly?
It's likely not working because the URLs for your PDFs are not being routed through Craft, thus Retour never even enters the mix.
This is normally how you'd want things to work, btw... you generally don't want static asset URLs to route through Craft, rather you want the web server to serve them up directly.
So you'd need to either add these redirects via your web server, or you'd need to ensure that .pdf
URLs are routed through Craft.
It's likely not working because the URLs for your PDFs are not being routed through Craft, thus Retour never even enters the mix.
The pdfs are uploaded into assets so afaik they should be routed through Craft.
That's probably not the case, but give me a URL to one of the PDFs and we can find out
We deleted the redirect pdf as part of the troubleshooting, but the target pdf to arrive at still exists in Craft.
Okay, in order for me to help you, I'd need to see a public URL to a PDF. Can you provide at least the now missing URL?
Andrew,
sorry about that
here is the missing pdf https://www.esscolab.com/uploads/files/E052r10-010522.pdf which should redirect to https://www.esscolab.com/uploads/E052r16-01032024.pdf
So when I curl it, I get this:
❯ curl -I https://www.esscolab.com/uploads/files/E052r10-010522.pdf
HTTP/2 301
server: nginx
date: Fri, 12 Jan 2024 20:07:22 GMT
content-type: text/html; charset=UTF-8
location: https://www.esscolab.com/uploads/E052r16-01032024.pdf
x-sucuri-id: 20039
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
content-security-policy: upgrade-insecure-requests;
expires: Thu, 31 Dec 2037 23:55:55 GMT
cache-control: max-age=315360000
x-sucuri-cache: EXPIRED
So it's a 301
redirect to this location: https://www.esscolab.com/uploads/E052r16-01032024.pdf
And that location does indeed seem to be the right PDF file. If I paste that first URL into the browser, I'm redirected to the correct URL and I see the PDF.
What am I missing here?
Andrew,
Update from the client based on reporting that it was working for you (above response)
Yes, the redirect will typically work if someone has not previously gone to the old URL. I was really just looking for guidance on the correct way to add PDF URLs to Retour:
How are we supposed to establish redirects for PDF files in Retour? Does it need to be Exact Match or RegMatch? Does the legacy file need to be deleted for the redirect to work?
Please advise
That sounds to me like a browser caching issue then? Try dumping the cache or shift-reloading the page or such. You could mitigate this by ensuring that PDF files are never allowed to be cached by the browser, but unless you're doing this constantly, that wouldn't be the best experience for people loading the PDFs.
To answer their questions:
Craft: 4.5.6.1 Retour: 4.1.13
Question
We're having some issues with redirecting pdfs with retour. Feel like it should work but it's not.. We've cleared cache multiple times as well as confirmed that the legacy pdf no longer exists in Craft or on disk anywhere.
A few questions to ensure that we're doing this correctly.
Here is a screenshot of the exiting redirect: have removed the part circled in red - nc change. Have also changed path only to full url with the actual domain
Please advise