Description
Hello,
I use nginx and the defined rewrite rules to serve cache files found here:
https://wordpress.org/support/article/nginx/#wp-super-cache-rules
Problem:
Search engines were flagging my cached site with duplicate content.
http://example.com/url and
http://example.com/url/
Reproduce:
First visit http://example.com/url/ (to cache the file), then visit http://example.com/url (an expected WP redirect will not occur, the cached file will be served.)
The Issue:
In the line
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args;
The extra slashes cause file mismatches.
$http_host
will contain a trailing slash by default.
$cache_uri
will be either url
or url/
in my examples.
Because the instructed code has slashes, both requests will match a cached file and cause SEO problems.
The correct line should be delimited with NGINX ${variable} notation and not hard-coded slashes.
try_files /wp-content/cache/supercache/${http_host}${cache_uri}index.html $uri $uri/ /index.php?$args;
This will result in not-found file when $cache_uri
is just url
and allow WP to do it's standard redirect.
Hope this helps someone in the future.
Activity