• Resolved ugoclemente

    (@ugoclemente)


    Hi,
    I am working at the test version of my website, test.my-site.com and I noticed that I couldn’t publish my posts, neither update em.

    When I tried to publish a post, an error message appeared: “Publishing failed. The response is not a valid JSON response.”.

    I noticed that if I tried to reach the URL https://test.my-site.com/wp-json I had a 404 error page.

    So I tried to reach https://test.my-site.com/index.php/wp-json and it worked.

    I temporarely solved the problem by setting the permalinks of the site (WP Panel > Settings > Permalinks > Custom structure) this way: /index.php/%postname%/.

    But now I would like to set the permalinks back to “Post name”.

    Is there any way to remove “index.php” from the base path of WordPress Rest API, in order to use the simple “https://test.my-site.com/wp-json” path?

    Where can I find the configuration file of WordPress Rest Api?

    Thank you very much.

    • This topic was modified 3 years, 6 months ago by ugoclemente.
    • This topic was modified 3 years, 6 months ago by ugoclemente.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter ugoclemente

    (@ugoclemente)

    [SOLVED] I found a solution here: https://stackoverflow.com/questions/67133365/how-to-get-rid-of-index-php-in-url-with-wordpress-rest-api

    Here is the procedure:

    1. edit the apache2 config file
    nano /etc/apache2/apache2.conf

    2. ensure the following rows are set this way

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

    3. edit the .htaccess file
    nano /var/www/test.my-site.com/.htaccess

    2. ensure the following rows are set this way

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (.+) index.php/$1 [L]

    Thank you anyway. Have a nice day!

    • This reply was modified 3 years, 6 months ago by ugoclemente.
    • This reply was modified 3 years, 6 months ago by ugoclemente.
Viewing 1 replies (of 1 total)
  • The topic ‘[SOLVED] WordPress Rest API – how to remove index.php from the base path’ is closed to new replies.