How do I fix a Cloudflare 301 too many redirects loop?
Switch Cloudflare SSL/TLS mode from Flexible to Full (Strict) so Cloudflare connects to your origin over HTTPS instead of hitting your port 80 redirect.
HTTP 301 Moved Permanently tells browsers and search engines a URL has permanently moved. Misconfigured 301 rules cause infinite HTTPS redirect loops, dropped POST payloads, and sticky browser caches.
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
curl -i -sS -L --max-redirs 5 http://www.example.com/
Switch Cloudflare SSL/TLS mode from Flexible to Full (Strict) so Cloudflare connects to your origin over HTTPS instead of hitting your port 80 redirect.
Yes. Google treats 301 and 308 permanent redirects as strong canonical signals and transfers link equity to the destination URL.
Use HTTP 308 Permanent Redirect instead of 301 for API endpoints that receive POST, PUT, or PATCH requests.