cachify icon indicating copy to clipboard operation
cachify copied to clipboard

nginx example hdd-cache creates possibility of multiple trailing slashes in url

Open karlkowald opened this issue 5 years ago • 1 comments

He, we are using cachify for long time and our prefered method is hdd caching with nginx setup.

works fine but now we found a problem at our server setup, that if we use caching and there is a hit, then its possible that urls could have multiple slashes in URL at the end and its always the same response.... ie: https://domain.com/the-slug/ is cached... then those urls all returns the cached site: https://domain.com/the-slug// https://domain.com/the-slug/// https://domain.com/the-slug////

Thats naturally not very good for duplicate content resons (although canonical helps there already).

my Quickfix now is this solution above your nginx.conf:

merge_slashes off;
rewrite ^(.*?)//+(.*?)$ $1/$2 permanent;

This lets nginx redirect first the multiple slashes before it searches for cached files on hdd.

perhaps you have a smarter solution for it, pls let me know :)

karlkowald avatar Mar 04 '21 20:03 karlkowald

This behaviour is not limited to nginx. It's the same on Apache.

Without the cachify, WordPress automatically redirects to the "single-slash" version.

derweili avatar Mar 29 '21 21:03 derweili