-1

I have correctly setup my site locally and everything works. However, when I deployed that to a blank EC2 instance, I see that wp-json (Rest API) does not work. It works only when I put an index.php in between. In other words

This works locally:

http://localhost/wordpress/wp-json

But I need to have this on the EC2 server to make it work.

http://A.B.C.D/wordpress/index.php/wp-json

On the server, I have installed apache2 and I have not messed up with the configs yet. I am familiar with wordpress but I not so much familiar with config tweaks on apache. I have also gone thru thousands of previously posted questions, but none of them seem to answer my problem.

1

1 Answer 1

2

First, you need to have by a2enmod rewrite in your terminal.

Then in your Apache Configuration file, make sure you have the following:

<Directory #Wordpress directory here#>
    Options Indexes FollowSymLinks
    AllowOverride All #allows .htaccess directives in the next step
    Require all granted
</Directory>

Then make sure you have the following content in your root .htaccess file:

RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+) index.php/$1 [L]
Sign up to request clarification or add additional context in comments.

1 Comment

Please consider making my answer as accepted if you found it to be useful

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.