Report this

What is the reason for this report?

ERR_TOO_MANY_REDIRECTS error after configuring HTTP Routes Redirect

Posted on September 10, 2023

I have a static website running on apps as starter plan. My web site has a directory like ‘abc’, including 2 files (one of them is index.html). When I request like mydomain/abc, there is no problem. The index.html within the abc folder works as it’s expected. However, when I click other pages on the site after requesting mydomain/abc, the application works as in the root directory unlike in the abc folder. So, I cannot request the other page in the abc folder. I get 404 error because the application works as in the root folder and expects it in the root folder.

To solve the problem, I configured an HTTP Routes Redirect definition like routepath: /abc, redirecturi: /abc/index.html in app settings. This time, I started to get ERR_TOO_MANY_REDIRECTS error when I requested like mydomain/abc. Actually, I don’t understand what the exact problem is. Any advice?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Based on your description, it sounds like when you access mydomain/abc, it redirects to mydomain/abc/index.html. Then, it’s possible the App Platform’s routing rules interpret /abc/index.html as needing to be redirected back to /abc, causing the loop. Consider removing this redirect rule entirely, as the App Platform will most likely automatically serve index.html when accessing a directory.

Also, if you’re using an SPA setup or something similar, you may need to set up fallback behavior. For SPAs, if the route doesn’t match any known routes, it should fall back to index.html (or the equivalent). What you could try doing is to setup a Catchall page in your App settings as described here:

https://docs.digitalocean.com/products/app-platform/how-to/manage-static-sites/#configure-a-static-site

Let me know how it goes after those changes!

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.