10up / safe-redirect-manager

A simple HTTP redirection plugin for WordPress.
https://wordpress.org/plugins/safe-redirect-manager
GNU General Public License v2.0
311 stars 82 forks source link

Wildcard redirects conflict when redirecting to parent URL #374

Open jessuppi opened 5 months ago

jessuppi commented 5 months ago

Describe the bug

Firstly, thank you so much to @10up and team for their incredible contributions to open source over the years, and beyond that, offering an inspiring example of good ethics and good quality to the community. You have impressed me for a long time and I should say this publicly somewhere, so thank you.

This might not be a "bug" because it seems like the plugin is meant to behave this way: https://github.com/10up/safe-redirect-manager/pull/182

However, I think it could be considered a bug. Here's an example scenario:

  1. Tons of 404 errors/spam queries are being sent to "child" pages of a given parent page such as:
  1. In this scenario, we use Safe Redirect Manager and add a new rule:
  1. This currently results in a redirect loop, because /* is treated the same as / in Safe Redirect Manager, which appears to be by design. However, if possible, I would suggest treating these differently, unless it's difficult because of WordPress limitations and the way trailing slashes are interpreted?

I have tried using regex for this scenario, and it seems the child redirects work, but the parent page still gets stuck in a redirect loop in the tests that I ran.

Steps to Reproduce

  1. redirecting wildcard children /page/* to parent /page/ results in redirect loop

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress information

No response

Code of Conduct

icodeforlove commented 5 months ago

One solution is to just not use paths which require a / at the end as this is not too common of a approach.

For example:

This way the wild cards would still work.