Skip to content

Trailing slash rewrite - duplicated content SEO issue #1035

Answered by lcrilly
sinedoOo asked this question in Support
Discussion options

You must be logged in to vote

This routes array should do what you want

[
  {
    "match": {
      "uri": "/*/"
    },
    "action": {
      "rewrite": "`${uri.slice(0,-1)}`",
      "return": 301,
      "location": "$uri"
    }
  },
  {
    "action": {
      "return": 204
    }
  }
]
$ curl -i http://localhost/foo/bar/
HTTP/1.1 301 Moved Permanently
Location: /foo/bar
Server: Unit/1.31.1
Date: Mon, 18 Dec 2023 10:44:12 GMT
Content-Length: 0

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by sinedoOo
Comment options

You must be logged in to vote
8 replies
@lcrilly
Comment options

lcrilly Dec 19, 2023
Collaborator

@sinedoOo
Comment options

@lcrilly
Comment options

lcrilly Dec 19, 2023
Collaborator

@ac000
Comment options

ac000 Dec 19, 2023
Collaborator

@sinedoOo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1034 on December 18, 2023 10:42.