0

I am building a word-press website, and I have changed my domain name from websiteold.com to websitenew.com.

The domain transfer was done by the web server host.

However, I am not able to use the rest API since I changed to the new domain name. This is the error I am getting from postman.

{
    "status": "error",
    "error": "UNAUTHORIZED",
    "error_description": "Sorry, you are not allowed to access REST API."
}

I have generated a new API key using the application passwords plugin, however whether I use the generated API key or a random/false API key, I get the same response.

Any suggestions as to why this is happening. It might have to do with configurations being associated with old domain name. Please advise what to do.

2
  • 1
    did your domain also do the database URL migration? Or did you do that?
    – Tom J Nowell
    Feb 7, 2022 at 15:30
  • that only goes so far though, the URLs appear in many more places, all tables need to be processed
    – Tom J Nowell
    Feb 8, 2022 at 9:46

2 Answers 2

3
+50

WordPress stores the domain of the installation in several places of the database. So you have to change them in numerous tables. In the case of working, look at the options table, entries siteurl and homeurl. It is also possible to set this via wp-config.php:

// Home URL of your WordPress.
define( 'WP_SITEURL', 'https:/example.com' );
// URL to the WordPress root dir.
define( 'WP_HOME', 'https://example.com' );

Look also inside the wp-config.php for the domain, because it is possible to set this via constant. The .htaccess, if it is an Apache server, should also validate, because the Permalink rules need the domain, especially in the 'Multisite' mode.

You should also active the debug mode, constant WP_DEBUG set to true in your wp-config.php to get more information about your installation, your problem. It should also help to find the issue with the REST API after domain change.

If it works fine, check also the whole database for the old domain. Because WordPress stores in various tables. A change for them is possible via SQL statement or a plugin, like 'Serach Replace'. More notes for a changing of the URL are also inside the codex - https://wordpress.org/support/article/changing-the-site-url/

1
  • Yes, issue was in the wp-config and url/home route in the db file
    – The Oracle
    Feb 8, 2022 at 6:55
0

Did you change all strings in the WordPress database from old domain to new domain? You can use some plugins (e.g. better search replace) or wp cli. E.g. to change from old domain to new domain, you can use old string: https://olddomain.com and new string https://newdomain.com

Also, try clearing cookies and redirections cache in the browser (ctr+shift+del on Windows, cmd+shift+backspace for Mac).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.