• Resolved manish21

    (@manish21)


    WordPress version 4.9.8

    I am running on localhost using apache server.
    Tried the following
    Permalink Settings : Post Name
    Enabled in Apache webserver
    LoadModule rewrite_module libexec/apache2/mod_rewrite.so
    Added file .htaccess
    cat .htaccess
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    curl https://localhost/wp-json/wp/v2/pages
    <!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
    <html><head>
    <title>404 Not Found</title>
    </head><body>
    <h1>Not Found</h1>
    <p>The requested URL /wp-json/wp/v2/pages was not found on this server.</p>
    </body></html>

    curl https://localhost/?rest_route=/wp/v2/pages
    <html><body><h1>It works!</h1></body></html>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You shouldn’t ever be getting Apache 404 messages. The WordPress nothing found sort of 404, yes, but not Apache 404. The RewriteCond rules in .htaccess enable this. Do other permalinks like localhost/hello-world/ work?

    Thread Starter manish21

    (@manish21)

    Started working after making these changes to apache
    AllowOverride All

    <Directory “/Library/WebServer/Documents”>
    #
    # Possible values for the Options directive are “None”, “All”,
    # or any combination of:
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that “MultiViews” must be named *explicitly* — “Options All”
    # doesn’t give it to you.
    #
    # The Options directive is both complicated and important. Please see
    # https://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks Multiviews
    MultiviewsMatch Any

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be “All”, “None”, or any combination of the keywords:
    # AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
    </Directory>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting 404 for Rest API’ is closed to new replies.