Skip to content

Documentation - NGINX Rewrite Rules cause Duplicate Content issues in SEO #25489

Open
@smartssa

Description

@smartssa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Docs[Plugin] Super CacheA fast caching plugin for WordPress.[Type] EnhancementChanges to an existing feature — removing, adding, or changing parts of it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions