Rank Math Redirection Issue

Home Forums BulletProof Security Pro Rank Math Redirection Issue

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #45200
    Ian
    Participant

    Hi,

    This was previously working but has stopped for some reason.

    We have Rank Math configured so that any 404 errors, the user is redirected to the homepage.

    That has stopped working and instead the user is being redirected to the 404 page instead.

    I did some testing from rank math and have found out it points to a permalinks issue and I think some code in one of the bullet proof files.

    I was asked to switch permalinks from Post Name to plain and test.

    When I did that, the redirect worked and took me to the homepage as desired.

    I also noticed a bullet proof warning and a link to this: https://www.ait-pro.com/aitpro-blog/2304/misc-projects/wordpress-tips-tricks-fixes/permalinks-wordpress-custom-permalinks-wordpress-best-wordpress-permalinks-structure/

    Can you please help me and tell me what to update in Bulletproof?

    Many thanks,

    #45201
    AITpro Admin
    Keymaster

    RankMath has it’s own settings to create 404 rewriting at the database level and also has an advanced feature that allows you to add/edit 404 redirect htaccess code in your root htaccess file.

    To allow RankMath to control 404 redirects instead of BPS do the steps below.

    Copy the modified BPS Pro Error Logging and Tracking htaccess code below into this BPS Root htaccess Custom Code text box: 5. CUSTOM CODE ERROR LOGGING AND TRACKING
    Click the Save Root Custom Code button.
    Go to the Setup Wizard page and click the Pre-Installation Wizard and Setup Wizard buttons.

    # BPS PRO ERROR LOGGING AND TRACKING
    # Use BPS Custom Code to modify/edit/change this code and to save it permanently.
    # BPS Pro has premade 400 Bad Request, 403 Forbidden, 404 Not Found, 405 Method Not Allowed and 
    # 410 Gone template logging files that are used to track and log 400, 403, 404, 405 and 410 errors 
    # that occur on your website. When a hacker attempts to hack your website the hackers IP address, 
    # Host name, Request Method, Referering link, the file name or requested resource, the user agent 
    # of the hacker and the query string used in the hack attempt are logged.
    # All BPS Pro log files are htaccess protected so that only you can view them. 
    # The 400.php, 403.php, 404.php, 405.php and 410.php files are located in /$bps_plugin_dir/bulletproof-security/
    # The 400, 403, 405 and 410 Error logging files are already set up and will automatically start logging errors
    # after you install BPS Pro and have activated BulletProof Mode for your Root folder.
    # If you would like to log 404 errors you will need to copy the logging code in the BPS Pro 404.php file
    # to your Theme's 404.php template file. Simple instructions are included in the BPS Pro 404.php file.
    # You can open the BPS Pro 404.php file using the WP Plugins Editor or by using the BPS Pro File Manager.
    # NOTE: By default WordPress automatically looks in your Theme's folder for a 404.php Theme template file.
    
    ErrorDocument 400 /wp-content/plugins/bulletproof-security/400.php
    ErrorDocument 401 default
    ErrorDocument 403 /wp-content/plugins/bulletproof-security/403.php
    #ErrorDocument 404 /404.php
    ErrorDocument 405 /wp-content/plugins/bulletproof-security/405.php
    ErrorDocument 410 /wp-content/plugins/bulletproof-security/410.php
    #45205
    Ian
    Participant

    Hi,

    Many thanks for that. We do have it running on two sites almost identical, and it rankmath redirection works on the other website.

    I just added your code and when I click the Save Root Custom Code button, I get this error:
    <h1>502 Bad Gateway</h1>
    The server returned an invalid or incomplete response.

     

    #45206
    AITpro Admin
    Keymaster

    Double check that you copied the htaccess code correctly and that you pasted it into the correct Custom Code text box. If your host server has ModSecurity installed you will need to click the Encrypt Custom Code button first and then click the Save Root Custom Code button. A 502 error is most commonly caused by Cloudflare. Clear/delete Cloudflare cache, any other caching plugin cache if you have another caching plugin installed and clear your browser cache.

    #45208
    Ian
    Participant

    Hi,

    It saved when I encrypted.

    However I am still getting the same issue.

    Have cleared all caches etc.

    I will log a call with them, but thought I would ask if you had any other ideas, just in case?

    Thanks

    #45210
    AITpro Admin
    Keymaster

    If you want me to login to your site and see if this is something that can be fixed on the frontend of your site then send me a WordPress Administrator login to your site: info@ait-pro.com. Most likely this is a ModSecurity backend problem that needs to be fixed by your host.

    #45221
    AITpro Admin
    Keymaster

    The problem was that you forgot to choose the RankMath “Redirection Type” for 404 errors. A 404 error should always use a 301 permanent move redirect.

    #45222
    Ian
    Participant

    Thank you so much for taking the time to look at this, I really appreciate it.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.