• Resolved ecabral

    (@ecabral)


    I’m using MAMP for MacOS. Webserver is Apache. All was working fine until I started getting 404 errors earlier today as I was performing some updates/editing.

    I’ve spent a couple of hours trying to find a solution in different foruns/articles. As instructed elsewhere I saved Permalinks (tons of times by now) to regenerate .htaccess, cleared cache, disabled all plugins, have twenty twenty-four enabled. Nothing works. Site Health Status displays the following message:

    The REST API encountered an unexpected result

    The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.

    When testing the REST API, an unexpected result was returned:

    REST API Endpoint: https://localhost:8888/wordpress/wp-json/wp/v2/types/post?context=edit
    REST API Response: (404) Not Found

    How can I fix this?

    Thanks!

Viewing 15 replies - 1 through 15 (of 15 total)
  • threadi

    (@threadi)

    Is https://localhost:8888/wordpress/wp-json/ available for you? Simply open it in your browser; depending on the browser you are using, a JSON view should appear. If this does not work, there is probably something wrong with the Apache configuration. It is probably not executing the .htaccess file.

    Thread Starter ecabral

    (@ecabral)

    Hi @threadi – That page is also showing a 404…

    Anything else I should do?

    If this does not work, there is probably something wrong with the Apache configuration. It is probably not executing the .htaccess file.

    Did you check your Apache configuration?

    Someone had a similar problem with MAMP here: https://stackoverflow.com/questions/65417541/apache-doesnt-seem-to-be-detecting-my-htaccess-file

    If that doesn’t help, ask in a community that supports MAMP. They are more familiar with its technicians.

    Saw (and replied to) your question on Stack Overflow (which was closed by the community due to it being off-topic.)

    You said you “saved permalinks a ton of times”, did you also try changing the permalink structure from the default one (Plain) to one of the other available options? (eg. Post Name)

    Thread Starter ecabral

    (@ecabral)

    @hcabrera – yes, saw that. Thanks for responding! (thanks @threadi too!)

    I changed permalink structure several times at random, but never to the Plain structure, I realize. I was actually under the impression that Post Name was the default, perhaps because that’s how I ALWAYS have mine structured and am not a fan of Plain for SEO.

    Anyhow, I just changed to Plain and can now view the pages/posts (!!). The REST API error is gone too from Site Health Status. No other structure works, though. All the others return 404s and the REST API error.

    There’s still something off here, though, as this is definitely not how I had permalinks structured before and it worked. And, I now seem to be stuck with Plain! I still have all plugins disabled and the default twenty twenty-four theme on, so there shouldn’t be any conflict.

    Any ideas of where else to look?

    Well, that’s progress I suppose. So the site works with Plain permalinks but not with the other ones. I’d say that something may have gotten messed up with your Apache install as threadi suggested.

    What does your httpd.conf file look like? (Use something like pastebin.com, don’t paste your httpd.conf contents here).

    Thread Starter ecabral

    (@ecabral)

    Here is the file. It’s located in C:\MAMP\conf\apache\httpd.conf, which is its default location per this page.

    There is an additional httpd.conf located in C:\MAMP\conf\apache\original\httpd.conf. I don’t know if that’s relevant but here is a side by side comparison of the two files.

    Thanks for taking a look!

    In which directory is your WordPress located? In /Applications/MAMP/htdocs or another one?

    Thread Starter ecabral

    (@ecabral)

    /Applications/MAMP/htdocs/Wordpress . I never changed it.

    The one thing I noticed is that the mod_rewrite module seems to be disabled on your server:

    #LoadModule rewrite_module modules/mod_rewrite.so

    I believe it should look like this instead:

    LoadModule rewrite_module modules/mod_rewrite.so

    So try removing that # at the beginning of that line, save changes, then restart (or stop and start again) your Apache server.

    Thread Starter ecabral

    (@ecabral)

    @threadi – tried that, but it didn’t work with me.

    @hcabrera – Eureka! It’s working now!! :-)) I wonder what might have disabled it?!!

    That’s great news, @ecabral!

    The mod_rewrite module is -iirc- disabled by default. Usually when you first set up a site with MAMP (or anything that uses Apache) you need to enable it manually (via command line or by editing the httpd.conf file), especially if you’re working with projects that require URL rewrites like WordPress.

    You must have enabled it at some point (or someone did for you?) otherwise permalinks wouldn’t have worked at all from the start. Why was mod_rewrite disabled? No idea to be honest, it couldn’t have disabled itself so my best guess is that the httpd.conf file was somehow reverted back to its original version? A mystery for you to figure out ??

    Anyways, happy coding and have a great day!

    Thread Starter ecabral

    (@ecabral)

    Mmm… The file was never manually edited until today and I do remember successfully changing permalinks before… Something must have triggered that change, but I’m clueless as to what.

    Anyway, thanks so much for your help!

    Most likely this has happened after MAMP update to 7.x. I just had the same problem, I had luck to link it to the update and I’ve discovered that 6.9 works fine, 7.0 and up – has problems. I’ve spent some time searching and this was the only thread I’ve found so far regarding the issue. And yes, Apache delivered with 7.x has mod_rewrite disabled.

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.