Rank Math Data not saving

#255613
  • Resolved Nurianta
    Rank Math free

    Hi,

    Rank Math is not saving new information, it’s not updating. I think there is a conflict with a piece of code in htaccess, the one forcing trailing slash.

    I have tried several ones and it’s not working, like this one:

    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} /+[^.]+$
    RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
    </IfModule>

    When I leave that code, Rank Math doesn’t save the changes and I see an error in /wp-json/rankmath/v1/updateMeta/?_locale=user. However, I need that code in the htaccess so I don’t have duplicated URLS with and whithout the final slash.

    Could you help me, please?

    Thanks

Viewing 12 replies - 1 through 12 (of 12 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math about your postmeta not saving when you activate the .htaccess trailing slash redirect.

    I tested the redirect on my own setup and the postmeta was saving. The usual cause of an error with wp-json/rankmath/v1/updateMeta is a firewall block. The following article details how to fix firewall blocks with WordFence: Firewall Blocked Access to the File. If you do not have WordFence the block may be on another security plugin, CDN like cloudflare, or on your hosting server.

    If the above does not work, we might need to take a closer look at the settings. 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.

    Hello,

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

    Thank you.

    Hello,

    I’ve checked your site and replicated the issue upon saving the keywords.

    Could you please confirm if you have already contacted your web host like my colleague mentioned above to check for any firewall that blocks the updateMeta rule?

    Looking forward to helping you.

    Thank you.

    Hi Reinelle,

    Thanks for your answer. Yes, I contacted my hosting service and they confirmed there is no firewall blocking.

    Regards

    Ankit
    Rank Math business

    Hello,

    I checked your .htaccess file and found that the below rule was causing the issue, I have removed the rule from the .htaccess and now the keyword data is saving fine.

    <IfModule mod_rewrite.c>
    	RewriteCond %{REQUEST_URI} /+[^\.]+$ 
    	RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
    </IfModule>

    Could you please kindly update the keywords and let us know how it goes.

    Looking forward to helping you. Thank you.

    Hi Ankit,

    Yes, that code was causing the issue, but I don’t want to delete it because I want the code to force the trailing slash at the end of the urls of the site. Is there a way to solve it while keeping that code, please? Or is there another code I can use?

    Thanks

    Nigel
    Rank Math business

    Hello,

    I tested the below snippet and it works on my setup

    <IfModule mod_rewrite.c>
        RewriteCond %{REQUEST_URI} /+[^.]+$
        RewriteRule ^wp-json/rankmath($|/) - [L]
        RewriteRule  ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
    </IfModule>

    Let us know how it goes. Thank you.

    Hi!

    Thanks, but it doesn’t work on my side or at least I cannot make it work. Depending on where I add it in the htaccess file I get two results: it doesn’t make the redirect to the trailing slash URL or all the URLS make a 301 to homepage. Maybe I’m not adding it right? Sorry for the trouble.

    Nigel
    Rank Math business

    Hello,

    I took a look at your htaccess and changed the snippet as below and successfully tested it:

    
    <IfModule mod_rewrite.c>
        RewriteCond %{REQUEST_URI} /+[^.]+$
        RewriteCond %{REQUEST_URI} !^/wp-json/
        RewriteRule  ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
    </IfModule>
    

    Let us know how it goes for you.

    Hi,

    It doesn’t make the redirection to the trailing slash. Does it work the redirect to you? In an URL without slash.

    Also, did you changed all my htaccess? I had important information and redirections that needed to be done! Why did you do that??

    .

    Nigel
    Rank Math business

    Hello,

    I have removed the line RewriteCond %{REQUEST_URI} !^/wp-json/ to restore the htaccess to its original state at the beginning of the ticket. No other changes were made to the rest of your rules at any time.

    I used an htaccess checking tool to test the rule I provided my last reply. The following links show the results of the test :

    htaccess action adds a slash
    If first folder is wp-json, no trailing slash added

    I am not sure why it is not working on your setup.

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

You must be logged in to reply to this ticket.