Cloudflare Pages: get rid of redundat 308 redirect

I’m migrating our Gatsby project from Netlify to Cloudflare Pages.

My website is currently hosted on Netlify

We have had a clean URL structure on Netlify (without slash at the end) and I want to keep it that way for the best SEO performance. To achieve this on Netlify we just had to disable the “Pretty URL” option (can’t post a link, sorry).

However, Cloudflare Pages adds a redundat 308 redirect and a slash at the end of the URL:

This lowers our Lighthouse Speed scores:

And may cause other unwanted issues (SCHEMA, crawling and indexing issues for search engines). Since our project is strictly focused on top SEO performance, we can not allow this.

Do you have any ideas how to solve this problem?

Page rules?

1 Like

The “trailing slash” issue has been covered several times:

https://community.cloudflare.com/search?q=pages%20trailing%20slash

2 Likes
  1. Page rules don’t work. We get a redirect loop.

  2. For htaccess we use this and it doesn’t work either.
    RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301]

  3. There are many unsolved topics related to this topic:
    Cloudflare Pages: Disable Non-Trailing Slash 308 Redirect
    Cloudflare Pages Remove Trailing Slash - #2
    Url forwarding page rules

EDIT:

ok I now see what you mean.
Can you please tell us if “URL Normalization” is turned on? Maybe thats the cause.

1 Like

One of these was turned on.

It is now disabled. It didn’t help.

Preview below. Chrome, no cache, private window:

I’m checking redirects status with this tool:
https://httpstatus.io/

This has been raised with the team, they will discuss it and decide what to do. They do see the issue.

4 Likes

Is there any way we can monitor the status of this specific issue? How do I know if / when it’s fixed?

1 Like

Is there any update from the team? Just came accross the same issue and tried everything: rules, functions, _worker, workers etc. Unfortunately nothing seems to be solving the problem for me. Either I’m getting TOO_MANY_REDIRECTS or the whole page stops working due to 522 and worker logs just respond with “Closed”.

@user8867 did you perhaps find a workaround?

1 Like

Hi @matteo. Is there any update on timing or a fix for this issue? I’m trying to migrate from Netlify to Cloudflare Pages asap, but this issue is a blocker.

Thanks,
Charlie

Yes, after days of testing I found a workaround.

Here’s what to do:

  • Deploy your site to Netlify. Make sure to add the domain on Netlify. Otherwise setup won’t work.
  • Point CNAME to your app on Netlify
  • Point A record to 75.2.60.5. It’s Netlify load balancer.

Optional

Cache everything with Cloudflare with Page Rules

Results

  • The slash and redirect issue is fixed
  • My site is hosted and deployed on Netlify
  • 90% of my traffic is proxied with Cloudflare

Replying to everyone here, I don’t have an update and the team is on holiday. Unfortunately I told all I know, and I’m not with the team, so nothing more I can do :frowning:

I’ll ask the team after the holiday period, but it was always a, we see the issue, we’ll consider the fix. They have a very big update coming on other things, after that, I presume they’ll fix other stuff.

2 Likes