Comments (12)
Ahhhhh that all makes sense now! Thanks for letting me know the cause.
from retour.
Show me a screenshot of the 404 you're seeing when visiting that original URL to the PDF?
from retour.
Hi Andrew, of course. Can I email you this? If so, what is the best address to send this to? Thanks.
from retour.
All I'm trying to determine is where it is an Nginx/Apache 404 error that's being displayed, or whether it is a Craft 404 error that's being displayed.
I can tell this by looking at what the 404 error message looks like; if it's a generic error message, then it's coming from your webserver. If it's a nicely formatted message, then it's coming from Craft.
This is relevant because if the 404 is coming from your webserver, and not Craft, then Retour never gets a chance to handle it.
Often this is the case because static resources like .pdf
files are configured to bypass Craft, and be served up directly by the webserver.
I suspect that's the case here, and if so, there's no way Retour can handle the redirect. You'll have to user a server-side redirect.
from retour.
Hi Andrew,
I just didn't want to post a client's screenshot publicly.
When logged into Craft as an admin, this is the 404 we see (I used the web inspector console to edit the URLs/paths: https://capture.dropbox.com/BRtgRkKO2PhEkktB
When not logged into Craft, we see the website's formatted/designed 404 template.
Thanks,
Stephen
from retour.
Okay so it is going through Craft -- so the Legacy URI must not be matching for some reason
from retour.
The Legacy URI matches (unless anything else is going on with the Forge/Nginx config that we haven't noticed), and we have tried Path Only as well as a Full URL. No matter how many times we refresh the old URL and load a 404, the Hits counter never rises above zero though, so Retour/Craft isn't seeing it for some reason, which is why we wondered if it was a bug with PDF's.
A redirect for https://www.ourwebsite.com/testing123/filename
works fine, but a redirect for https://www.ourwebsite.com/testing123/filename.pdf
doesn't work.
Do you have any other thoughts for things we might need to check for this at all? Thanks.
from retour.
Is it possible the .
needs to be escaped? I'll do some tests locally tomorrow to see if I can reproduce the issue here.
I really thought it was going to be that the static assets weren't routed through Craft (which is ideally what you'd want), but I'm guessing even if that's the case, the 404 does get routed through Craft.
from retour.
Okay I did a test locally and everything is working as expected with the example URLs you note above.
Therefore, I'm guessing there is some kind of server config issue on your end that might be interfering here?
![Screenshot 2023-10-24 at 09 10 12](https://private-user-images.githubusercontent.com/7570798/277667730-1fbe328c-3989-4634-8ff3-56e0a0d3f05f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NTc5NDQsIm5iZiI6MTcyMzg1NzY0NCwicGF0aCI6Ii83NTcwNzk4LzI3NzY2NzczMC0xZmJlMzI4Yy0zOTg5LTQ2MzQtOGZmMy01NmUwYTBkM2YwNWYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTdUMDEyMDQ0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDM4OGNkMGFjMDM0MzBmMzA1NGEwNjNmNzBmMzQyNDU1MGUzNTAwOWI0ZGNjNDgyZmZhMTY2Y2E4NzdhYmUyYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ._MYT2qTHHgpv_GLgVdOWv9ThVyZAE6FbSFY36EDS6FE)
![Screenshot 2023-10-24 at 09 10 24](https://private-user-images.githubusercontent.com/7570798/277667738-f5b11906-f5f9-446e-926a-3a73f80ac969.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NTc5NDQsIm5iZiI6MTcyMzg1NzY0NCwicGF0aCI6Ii83NTcwNzk4LzI3NzY2NzczOC1mNWIxMTkwNi1mNWY5LTQ0NmUtOTI2YS0zYTczZjgwYWM5NjkucG5nP1gt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ZjdjMjdkNDIyZWZhOGE0MDUxMDkwYzUxYjdkMzMzNzUyY2JlMjgyOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.RARFFKABqJ2BDZAgxSN-chmt4wQuKKwKpc98kA98WgI)
from retour.
Hi Andrew,
Thanks for looking into this one further.
You mentioned the server config, so I've copied and pasted our Laravel Forge Nginx config below for info in case anything jumps out at you that might explain the issue we're having (or to rule out this being an issue):
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.clientdomain.com/before/*;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.clientdomain.com;
server_tokens off;
root /home/forge/www.clientdomain.com/public;
# FORGE SSL (DO NOT REMOVE!)
ssl_certificate /etc/nginx/ssl/www.clientdomain.com/1234567/server.crt;
ssl_certificate_key /etc/nginx/ssl/www.clientdomain.com/1234567/server.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers <ciphers removed>;
ssl_prefer_server_ciphers off;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.clientdomain.com/server/*;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/www.clientdomain.com-error.log error;
error_page 404 /index.php;
rewrite ^/(.*)/$ /$1 permanent;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
location ~* (.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif|webp)$ {
try_files $uri $1.$2;
}
}
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.clientdomain.com/after/*;
Let me know if you spot any issues with anything here, or would like us to try anything else.
Thanks,
Stephen
from retour.
I don't see anything in there explicitly setting a location
block for pdf
files, so no, nothing offhand.
Are you able to reproduce this issue in your local dev environment?
from retour.
Hi Andrew, sorry for the delay in coming back to you about this one. I've tested this in a development environment today (using MAMP) and the same issue was happening there. After a lot of debugging, trial and error (and disabling other plugins, one by one), I eventually came across the cause of the issue! 😅
We had this in our Retour settings: Exclude Patterns: \.jpg|\.png|\.bmp|\.gif|\.pdf|\.doc|\.docx
Once I removed the .pdf
bit and saved the settings, the redirect worked fine and as expected!
The reason we added that pattern in the first place was because the Asset path changed after we implemented multi-site functionality a couple of years ago, and our Retour dashboard was getting filled up with 404s for files that had changed path, but which we didn't think were important to see/redirect, so we added the pattern to filter this 'junk' out. Little did we know then, that the client would want to add a redirect for a PDF file a couple of years later!
Sorry about this and for wasting your time helping us get to the bottom of it, but your help was much appreciated! Thanks, Stephen
from retour.
Related Issues (20)
- Auto redirect changed product slugs too
- Using Blue + button to go to Redirects page causes issue adding a new redirect
- Copying resources to /cpresources/retour/ HOT 2
- Link for documentation incorrect HOT 1
- 'No Data Available' on production HOT 1
- Plus signs "+" in exact match not redirecting. HOT 1
- CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xC0\xAEbar' for column 'redirectSrcUrl' at row 1
- Uncaught ErrorException: "iconv(): Detected an incomplete multibyte character in input string"
- Session expiring after short period with plugin enabled HOT 2
- Redirect Not Working
- [FR] Delete all handled redirects
- CSV Import results in "PHP Notice – yii\base\ErrorException – Undefined index: redirectMatchType" HOT 2
- craft.retour.getHttpStatus gives 200 after 301 redirect HOT 1
- Redirect Http Code is invalid, when creating new static redirect
- PDF Redirecting HOT 10
- Csv import seems to skip the first one HOT 1
- Switching Blitz to Cloudfront has broken Retour it seems HOT 3
- Add support for domaine redirect HOT 4
- Redirecting Subdomain to a Specific Section of the Main Site
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from retour.