Redirects to Container

Is there a way to create a page rule to redirect index files to their containing folder? I have some clients on managed WordPress environments (like FlyWheel, WPEngine, etc) who cannot manipulate their .htaccess.

Is there a rule that CF can use to do this?

To be clear, I want to redirect:

domain.com/folder/index.htm
domain.com/folder/index.html
domain.com/folder/index.php

All to:

domain.com/folder/

… to avoid duplicates, especially on some folders where it’s difficult to canonicalise.

Thank you.

Give this a try:

From: domain.com/*/index.htm

Setting: Forwarding URL - 301

To: domain.com/$1/

Create 2 more page rules for the rest of the index files.

I think the other issue is the passing of parameters or query strings, like:

From domain.com/folder/index.htm?query=string
To domain.com/folder/?query=string

Or from domain.com/folder/index.htm#anchor
To domain.com/folder/#anchor

I imagine a rule like yours but adding:

From domain.com/*/index.htm*

To domain.com/$1/$2

1 Like

On second thought, that won’t work with index.html, since the last letter would be passed on. I need to add something more specific.

OK, I trying it with two rules, one with .html first and then .htm. Looks like it’s working for now.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.