Redirections not working

#875143
  • Resolved Mike McDonnell
    Rank Math free

    I’m having trouble setting up redirects for image files located in the /wp-content/uploads/ folder using RankMath’s redirection feature and custom .htaccess rules.

    I’m trying to redirect old image URLs (e.g., /wp-content/uploads/2015/10/RusticMilano6AA.jpg) to the homepage (https://www.samleisure.co.uk). However, instead of the redirects working, I keep getting 404 errors when accessing those URLs.

    What I’ve Tried:

    1. RankMath’s Redirection Feature: Initially, I attempted to use RankMath’s built-in redirection tool, but it seems it cannot handle redirects for static files located in the /wp-content folder.
    2. .htaccess Manual Redirects:
    I added 301 redirects manually to the .htaccess file using the following format:

    Redirect 301 /wp-content/uploads/2015/10/RusticMilano6AA.jpg https://www.samleisure.co.uk

    I also tried using RedirectMatch to apply rules to all files in /wp-content/uploads/:
    RedirectMatch 301 ^/wp-content/uploads/.*$ https://www.samleisure.co.uk

    Could you provide guidance on resolving this issue using RankMath or advise on any possible conflicts or limitations with redirecting static files?

    Thanks in advance,
    Mike

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

    We apologize for the issue you are facing with the redirects for your image files. It seems like you’ve already tried a couple of methods to set up the redirects, but they are still resulting in 404 errors.

    Here are a few suggestions to help resolve the issue:

    1. Check .htaccess File: Ensure that there are no conflicting rules in your .htaccess file that might be causing the 404 errors. You can check your .htaccess file by navigating to WordPress Dashboard → Rank Math SEO → General Settings → Edit .htaccess. Make sure that your redirect rules are placed correctly and not being overridden by other rules.

      Edit .htaccess

    2. Backup and Restore: Since any mistakes in the .htaccess file can break your website, ensure you have a backup before making changes. Rank Math creates a backup of your last saved version, which you can restore if needed.

    3. Use Correct Redirect Syntax: The syntax you used for the manual redirects seems correct. However, ensure that there are no typos in the URLs and that the paths are accurate. For example:

      Redirect 301 /wp-content/uploads/2015/10/RusticMilano6AA.jpg https://rankmath.com/wp-content/uploads/2023/02/page-indexing-report-scaled.jpg

      and

      RedirectMatch 301 ^/wp-content/uploads/.*$ https://rankmath.com/wp-content/uploads/2023/02/page-indexing-report-scaled.jpg

      should work if placed correctly.

    4. Check File Permissions: Ensure that the image files in the /wp-content/uploads/ directory have the correct permissions set so that they can be accessed by the server.

    5. Debugging: If the issue persists, consider using Rank Math’s Debug Redirection feature to identify any potential issues with your redirects. This can help pinpoint what might be going wrong.

    6. Server Configuration: Sometimes, server configurations (like Nginx settings) can interfere with redirects. If you’re using Nginx, ensure that your configuration allows for these types of redirects.

    If after trying these steps you still encounter issues, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further.

    Thank you for raising this concern, and we hope to help you resolve it soon!

    Hello,

    Please note that Rank Math doesn’t support redirecting URLs from the site’s root folders like wp-content, wp-includes, etc.

    You will have to get in touch with your host and ask them to set a redirection rule in the server configuration file to redirect such URLs.

    The best way to achieve this redirection is via the .htaccess file like you have mentioned.

    Looking forward to helping you.

    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 2 replies - 1 through 2 (of 2 total)

The ticket ‘Redirections not working’ is closed to new replies.