Redirecting Attachment Pages To Media URL

#937763
  • Resolved Edd Bateman
    Rank Math free

    I have setup rankmath with buddyboss theme and following documentation did the settings. Now, I am facing issues with attachment pages. As mentioned in documentation and youtube tutorial I followed the same steps.

    Rank Math > General Settings > Links > Enable Redirection > Save

    After that adding this snippet in rank-math.php:
    /**
    * Redirect Attachments to media URL
    */
    add_filter(‘rank_math/frontend/attachment/redirect_url’, function ($redirect, $post) {
    return $post->guid;
    }, 10, 2);

    It Should Work as whenever attachment page link clicked its will redirect to media url but in my case this process is only working on staging site but for the main site its only redirecting to homepage or no redirection. I checked both orphan and in use images.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    After applying the settings and the code, please head over to your WordPress dashboard → Settings → Permalinks and save the settings without changing anything.

    If the issue persists, we may need to check your live website. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.

    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Edd Bateman
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Edd Bateman
    Rank Math free

    I implemented your suggestion. This time it works but only for one attachment out of 1000 of attachments only on most recent uploaded attachment while for other attachments they are not redirecting to media url while some are redirecting back to admin page /wp-admin and many on homepage. I have updated my wordpress & ftp details. Please check and fix it as soon as possible.

    Hello,

    The redirection to the attachment URL is happening correctly, but those attachments don’t exist on the website but they are in a cloud service so the attachment URL returns a 404 error and redirects to the homepage.

    This method will only work if the attachments are available on your own server, not hosted in a cloud service.

    Don’t hesitate to get in touch if you have any other questions.

    Edd Bateman
    Rank Math free

    Is there any specific method to redirect cloud stored attachments?

    Hello,

    No, in our plugin that is not possible. We can only properly redirect the attachment pages when the attachment is hosted on the server.

    To redirect to cloud-hosted files you would need a custom solution with a custom plugin but that is outside the scope of our support.

    Don’t hesitate to get in touch if you have any other questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)

The ticket ‘Redirecting Attachment Pages To Media URL’ is closed to new replies.