Home
Support Forums

Multiple trailing slashes issue for site root

Hello @all,
i’m running Nuxt.js site on Netlify and bumped into weird issue with HTTP status codes returned for the site root request.

the site is very basic; it is generated by the

$yarn create nuxt-app

Source code can be found here
For some reason Netlify generates different HTTP status codes depending on amount of trailing slashes specified in the request URL:
$ curl -I https://admiring-curie-585c96.netlify.app////
HTTP/2 301
cache-control: public, max-age=0, must-revalidate
content-length: 0
content-type: text/html; charset=UTF-8
date: Wed, 20 Jan 2021 15:17:22 GMT
etag: “7fde36f2c9f0b4b0c390a21dc763ca6d-ssl”
strict-transport-security: max-age=31536000; includeSubDomains; preload
age: 0
server: Netlify
location: /
x-nf-request-id: f0d4b89c-7ce8-4c3a-b983-77ef0ce6e049-35083606

$ curl -I https://admiring-curie-585c96.netlify.app///
HTTP/2 200
cache-control: public, max-age=0, must-revalidate
content-length: 0
content-type: text/html; charset=UTF-8
date: Wed, 20 Jan 2021 15:17:27 GMT
etag: “7fde36f2c9f0b4b0c390a21dc763ca6d-ssl”
strict-transport-security: max-age=31536000; includeSubDomains; preload
age: 0
server: Netlify
x-nf-request-id: f0d4b89c-7ce8-4c3a-b983-77ef0ce6e049-35086155

$ curl -I https://admiring-curie-585c96.netlify.app//
HTTP/2 200
cache-control: public, max-age=0, must-revalidate
content-length: 0
content-type: text/html; charset=UTF-8
date: Wed, 20 Jan 2021 15:17:30 GMT
etag: “7fde36f2c9f0b4b0c390a21dc763ca6d-ssl”
strict-transport-security: max-age=31536000; includeSubDomains; preload
age: 0
server: Netlify
x-nf-request-id: 51cdec21-0e42-4a13-affd-4b120bde3037-64253937

in case of 4+ trailing slashes the behaviour is correct - it generates 301 redirect to /, however in case of /// (three slashes) or // (two), Netlify generates http status 200 and produces the page.
The expected behaviour is to have 301 to / regardless the amount of the trailing slashes.
having http status 200 for /// and // can be treated by crawlers as separate pages even though the page is the same.
is the issue known? are there any workarounds?
Please advise.

Very interesting! I suspect that this is either/or being caused by Nuxt, or our Pretty URLs feature.

Let’s start with Pretty URLs. I can see that ‘Disable asset optimization’ is not checked (therefore AO is active) and Pretty URLs is checked (therefore Pretty URLs is active) for this site. Using these reproductions, particularly this one, we can see that content won’t be duplicated across trailing slash and non trailing slash variants of your site.

This can be proven by navigating to https://admiring-curie-585c96.netlify.app/index.html and https://admiring-curie-585c96.netlify.app/index.html/ or https://admiring-curie-585c96.netlify.app/subfolder/ and https://admiring-curie-585c96.netlify.app/subfolder// for example. So, it doesn’t look like it’s related to this directly.

So, now I’m scratching my head. I can see that, in your deployed files, you have up to 4 subfolders. I’d be interested to see if, if you created a page such as /1/2/3/4/5/6/index.html, whether the number of slashes you required in order to receive a 301 status code changes. If the number of required slashes does change, this looks like a routing issue in Nuxt.

Lastly, I’d be interested to see what impact the following redirect rule has:

/* / 301

I suspect that it won’t change anything, thus leading me to believe that this is a routing issue with Nuxt. Interested to hear what we find!

That is quite interesting, although I’m not sure I believe that’s a Nuxt concern :thinking: in the same reproduction,

cURL’ing to https://pretty-urls-checked-disable-ao-unchecked.netlify.app// results in a 200 and content.
cURL’ing to https://pretty-urls-checked-disable-ao-unchecked.netlify.app/// results in a 200 and content.
cURL’ing to https://pretty-urls-checked-disable-ao-unchecked.netlify.app//// results in a 301 to /

Following this thread for sure :stuck_out_tongue: Though from a pragmatic standpoint, I’m not sure how big a bug this could be — typically hitting a URL with multiple slashes is in itself a bug :stuck_out_tongue: multiple consecutive slashes like that may be HTTP valid (I’d have to look that up honestly) but would certainly be interpreted differently across different web-servers.


Jon

1 Like

dear Pie,
appreciate your prompt reply.
i suspected that amount of trailing slashes somehow is related to site folders structure.
to verify this assumption i created app with only one page, no subfolders at all.
the outcome is the same:

$curl -I https://adoring-noyce-922c2a.netlify.app///
HTTP/2 200
cache-control: public, max-age=0, must-revalidate
content-length: 0
content-type: text/html; charset=UTF-8
date: Thu, 21 Jan 2021 13:10:38 GMT
etag: "f933711a850612ae6f2722e83cbfabb7-ssl"
strict-transport-security: max-age=31536000; includeSubDomains; preload
age: 0
server: Netlify
x-nf-request-id: bb974f16-a628-411d-8bba-60bd6ce85c52-27190387

you were right, adding redirect rule didn’t change anything:

$ curl -I https://admiring-curie-585c96.netlify.app//
HTTP/2 200 
cache-control: public, max-age=0, must-revalidate
content-length: 0
content-type: text/html; charset=UTF-8
date: Thu, 21 Jan 2021 13:15:21 GMT
etag: "d43614524c5bde2ceaa2fd78064aece0-ssl"
strict-transport-security: max-age=31536000; includeSubDomains; preload
age: 0
server: Netlify
x-nf-request-id: 51cdec21-0e42-4a13-affd-4b120bde3037-94195596

Still have no clue is the issue related to Netlify or Nuxt.

Regards, Dmitry

P.S. there 2 different urls in the examples above. it’s the same app deployed against different branches with different folders structure. just to have both versions of the app available simultaneously

hey Jon,
that’s correct - before deploying my version of the site i’ve checked your app and noticed that the behaviour is the same :slight_smile:

I stripped back my thought process and checked this behaviour out on any ol’ .netlify.app domain.

https://propagation.netlify.app
https://propagation.netlify.app///

Turns out that this doesn’t relate to pretty URLs or AO in the slightest! It’s across the board, for all .netlify.app domains. I suspect it’s something to do with how up to 3 forward slashes are required or ‘addressable’ by a URL (with 3 forward slashes being used for localhost, et cetera). I’ll see what the wider team say :slightly_smiling_face:.

1 Like

hey @Scott,
thanks for your check. Let’s hope that the wider team can help us find an elegant solution.
As a workaround, to resolve the issue with SEO stuff, i just added canonical link to the site home page, i.e.

<link data-n-head="ssr" rel="canonical" href="https://mysite.com/">

Regards, Dmitry

For what it’s worth, @dmytro, since your main concern appears to be in regards to web crawlers and duplicate content — unless you’re specifically adding anchor tags that specify a trailing-double-slash or trailing-triple-slash, web crawlers aren’t even going to attempt to load trailing-doubles or trailing-triple paths. It’s very non-standard for webpages to use those paradigms and not something that a web crawler would even attempt to load unless you specifically have anchor tags in your HTML that point it in that direction. Canonical tags aren’t ever a bad thing per se but probably not needed in this case, IMO :slight_smile:

1 Like

Bang on the money, @jonsully :stuck_out_tongue:

That said, we do want this to be right! The wider team agree that there is an issue so I’ll get a bug filed on our end.

In short, different behaviours for / may be expected (based on trailing slash behaviour). Additionally, resolving up to /// is expected. However, for /// at least, the canonical link header isn’t right.

https://netlifyrodeo.netlify.app///
Link: <https://netlify.rodeo//>; rel="canonical"

I think // behaviour is OK as this defaults to a canonical link header with / – and so does a URL without a trailing slash. We 301 a trailing slash URL to the non-trailing slash URL, if that’s how the site is configured. Of course, this is for a site with a custom domain so a bit more thought will be needed for any sites without. But, I’ll leave it in the capable hands of our traffic team.

As the impact is low, I can’t promise any sort of quick turnaround on this but I’ll be sure to keep you posted with any developments. Appreciate you sharing your workaround too, @dmytro!

@jonsully i agree - rare and non-standard scenario. Let me share some background info :slight_smile: we have received results of SE audit from the agency. they complained that we are non double slash and url with and without trailing slash - friendly. I have no clue when they found urls on our site with multiple trailing slashes because they just don’t exist. adding canonical is a bit overkill, but to be 100% sure we’ve just added it and made seo guys a bit happier :slight_smile:

1 Like

hey @Scott, another note about redirects.
i have configured site with or without www. Domain name with www is set as primary.
if i do request to https://mysite.com// Netlify generates 301 with correct location to primary site (htts://www.mysite.com/).
so yes, there is an issue with redirects for sure :slight_smile:

NP with low priority of the ticket - since we identified the source of the issue and have workaround, we can live with it for some time.

Appreciate your assistance.

Regards, Dmytro

1 Like