Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with "Redirect Orphan Attachments" and Redirection Functionality #297

Open
thegulshankumar opened this issue Dec 18, 2024 · 0 comments

Comments

@thegulshankumar
Copy link

Steps to Reproduce

  1. Set up the following environment:

    • WordPress version: 6.7.1
    • PHP version: 8.3
    • Theme: Twenty Twenty-Three
    • Plugin: Rank Math
  2. Navigate to General Settings > Links > Redirect Orphan Attachments.

    • Notice that the default value is set to the homepage URL.
  3. Enable the "Redirect Attachments" module.

  4. Upload an image file, e.g., http-auth.png.

  5. Perform the following scenarios:

    • Scenario A: The media attachment URL becomes https://example.com/http-auth/.
    • Scenario B: Create a new post with the same permalink (http-auth), resulting in:
      • Post URL: https://example.com/http-auth/.
      • Media attachment URL: https://example.com/http-auth/http-auth/.
  6. If the post (http-auth) is deleted and you attempt to set up a redirection from https://example.com/http-auth/ to a new URL, such as https://example.com/new-url/, the redirection module exhibits inconsistent behavior:

    • Unattached Media: Redirects to the homepage.
    • Attached Media: Redirects to the original post instead of the new URL.

Problem Summary

The issue stems from the default behavior of the "Redirect Orphan Attachments" setting for non-attached media, which assigns the homepage URL by default.

Additionally:

  • URLs like https://example.com/http-auth/http-auth/ are not handled by the redirection module, further complicating user workflows.
  • Redirection to homepage cause frustration. Hard to debug attachment redirection due to unclear message in header x-redirected-by: rankmath, suggest you to kindly replace it with something else if possible.

Expected Behavior

When a redirection rule is applied (e.g., https://example.com/http-auth/ to https://example.com/new-url/):

  • Unattached media should respect the redirection rule instead of defaulting to the homepage.
  • Attached media should also follow the redirection rule, regardless of its association with a post.

Suggested Fix

  1. Ensure that the "Redirection Module" of Rank Math takes priority over the attachment media redirection settings for both attached and unattached media. This is crucial for scenarios where a user uses a common featured image and post name and needs to redirect to a new post after deleting the original.
  2. Verify that the redirection module consistently applies custom redirection rules.

Note: While the handling of URLs like https://example.com/http-auth/http-auth/ is not the primary focus of this report, it may still require attention to improve consistency and user expectations with Redirection Module.


Let me know if further clarification or testing is required!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant