Fix the WordPress REST API Authorization header

The complete DIY fix when a correct credential still returns 401 “not logged in”.

15 min read Advanced

The symptom

You connect WordPress with a correct username:application_password, but every REST write fails and a test returns: {"code":"rest_not_logged_in","message":"You are not currently logged in."} with HTTP 401, even though the same credential works in wp-admin.

The cause

WordPress Application Passwords authenticate using the HTTP Authorization header. Many hosts, Hostinger, and Apache/LiteSpeed with CGI/FastCGI, strip that header before it reaches PHP, so WordPress sees the request as anonymous. A quick tell: send a deliberately WRONG password and you get the exact same rest_not_logged_in error. If wrong and right passwords fail identically, the header is being stripped.

This is a hosting/server issue, not a WordPress or credential problem. Fixes below are ordered from least to most invasive, try them in order and re-test after each.

Fix 1, pass the header through .htaccess

Edit .htaccess in your WordPress root (usually public_html). In your host's File Manager, enable “show hidden files” to see it. Add this at the very top, above # BEGIN WordPress:

.htaccess (top of file)
CGIPassAuth On
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

CGIPassAuth On is the LiteSpeed/Apache 2.4.13+ directive that forwards the Authorization header to PHP; the rewrite lines cover Apache setups that don't honor it. Save, then re-test the connection.

If the page returns a 500 error after adding CGIPassAuth On, your server is older than Apache 2.4.13, remove just that one line and keep the rest.

Fix 2, disable / bypass the CDN

If a CDN sits in front of your origin (Hostinger's built-in CDN reports server: hcdn), it can strip the Authorization header before .htaccess ever runs. In your host panel, find the CDN setting (Hostinger: hPanel → Websites → your site → Performance → CDN), turn it OFF, and purge the cache. Re-test.

Make sure the toggle reads Disabled, not Enabled. Turn it back on later only if REST auth still works with it on.

Fix 3, the WordPress plugin (works even when the header is stripped)

If the header is stripped at the CDN edge and you can't disable the CDN, no server config can recover it, so route around it. The WordPress plugin you download from the dashboard takes a shared secret in the request BODY (which CDNs pass through) instead of the Authorization header, and it is the recommended way to connect in any case. See “Install the WordPress plugin”.

  • It applies approved fixes and publishes draft articles, nothing else.
  • It's locked to a random secret generated for your project.
  • Deactivate it any time to close the endpoints.

Verify it worked

Re-run the CMS connection test (or the audit's apply). Success looks like a 200 with your user and roles returned. If you still get 401 after Fixes 1-2, use Fix 3; if you get 403, the account isn't an Administrator/Editor.

Common questions

Will this break my site?

No. The .htaccess lines and the plugin only affect how the Authorization header is handled and add a scoped endpoint. Your public pages are unaffected. If CGIPassAuth causes a 500 on a very old server, removing that single line reverts it.

Is this safe on shared hosting?

Yes. These are standard, widely-documented fixes for Application Passwords on shared/LiteSpeed hosting. The secret endpoint is limited to setting alt text and is protected by a random secret.

Related guides

Still stuck?

We’ll get back within one business day.

Contact support