Skip to content

WordPress Errors

Had the following WordPress errors on a website I was working on. I had migrated from one server to another.

  • Cookie nonce is invalid
  • 404 errors for wp-json/wp/v2/posts

I finally tried this trick, adding index.php, to test the URL giving the 404 and it worked http://localhost/myproject/index.php/wp-json/wp/v2/posts.

I switched the Settings -> Permalinks from post name to plain and that worked as well. I put it back and the errors returned.

It ended up being that somehow during migration the .htaccess file was not copied over and was not set up on the new server. Once I copied the .htaccess file from the old to the new server it worked.

Here is a copy of what my .htaccess file looked like at that time.

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress
Published inWordPress

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.