Hi, @henrik. The issue you are experiencing is because your rules are not forced.
When you query this URL:
https://blog-johannaost-com.netlify.app/index.html?page=2
That page exists and because the rules isn’t forced it doesn’t apply at all. This just serves the page /index.htm
with a 200 response. Your query parameter never gets considered because the rule itself never applies.
Now, for the /debug
path, there is no just page for that site (no page /debug.html
or /debug/index.html
). This triggers the non-forced rule and redirects to /my-art-and-illustration
.
For the last example, this is the URL requested:
https://blog-johannaost-com.netlify.app/debug2?page=123
This is triggering the second redirect:
[[redirects]]
from = "/*"
query = {page = ":page"}
to = "/:splat-page-:page"
status = 302
There is no page so the /*
path matches - but only with a query parameter. Without the query parameter you get the expected 404. With a page
parameter the rule now works as follows:
- :splat = debug2
- :page = 123
With a to
setting of /:splat-page-:page
this redirects to the following path with a 302:
/debug2-page-123?page=123
Now, that also matches the same rule so it redirects to this:
/debug2-page-123-page-123?page=123
The redirect keeps rinsing and repeating to give you the long URL you posted:
https://blog-johannaost-com.netlify.app/debug2-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123-page-123?page=123
I think if you force the rule like so it will achieve the result you are looking for:
[[redirects]]
from = "/index.html"
query = {page = ":page"}
to = "/index-page-:page.html"
status = 200!
If that doesn’t work or if there are other questions, please let us know.