WordPress: How to connect Bitnami WordPress API on AWS Cloud

How possible if I post my article from somewhere outside WordPress backend?
How I get my blog posts to display on my main website? (blog.yourdomain.com get connected to yourdomain.com)

Yes, we can do that by using this plugin JWT Authentication for WP REST API

Scenario: I build up the main website with Reactjs and make a connection to the WordPress website.

After plugin have been installed, file .htaccess need to be modified
Add these codes to .htaccess file

RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]

and also this one

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

If you are using Bitnami WordPress on AWS, modify .htaccess file is not allowed. Read Bitnami advice here

According to above advice, file htaccess.conf needs to be modified (file location:/opt/bitnami/apps/wordpress/conf/htaccess.conf)

Add these lines of code to the bottom but before tag </Directory>

RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]

and this one after tag </Directory>

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

As shown below at line 37-42:

then edit wp-config.php file add these lines to the bottom

define('JWT_AUTH_SECRET_KEY', 'your-top-secret-key');


define('JWT_AUTH_CORS_ENABLE', true);

You can change ‘your-top-secret-key’ to any. That’s all.
Try this,
1. open Postman select POST and put your blog URL follow by /wp-json/jwt-auth/v1/token
2. Select Headers add KEY:Content-Type and VALUE:application/json

3. Select Body select raw and select JSON at the drop-down list in the most right add username and password as shown below
“username”: “yourusername for WordPress backend”,
“password”: “yourpassword for WordPress backend”

If everything correct then you will get token from API
Read How to use the token in the next Article

Leave a Reply