Support » Fixing WordPress » URL rewrites not working

  • Resolved thebenkahn

    (@thebenkahn)


    Hi, I have a new site I’m building out. Server is a Digital Ocean Ubuntu 18.04 running Apache 2.4 and PHP 7.2. Newest WordPress, 5.2.1 and the 2019 theme with only one plugin (Kadence blocks) installed. I turned on pretty permalinks and they are not working (get a 404 trying to visit posts/pages). The site still works fine with plain URLs.

    Site health check reports:

    The REST API call gave the following unexpected result: (404)
    Not Found
    The requested URL /wp-json/wp/v2/types/post was not found on this server.

    As far as I can tell my .htaccess file looks fine. I set chmod 666 on it and WP automatically adds/removes rewrite rules when I change permalinks to pretty/plain and save from the Settings->Permalinks page.

    I have pretty permalinks on now and see the following in .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

    For now I will just use plain URLs, but if anyone has any other ideas of things to try I’m all ears!

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Have you tried adding an index.php to the url?

    
    /index.php/wp-json/wp/v2/types/posts
    
    

    Stef, thank you, that works and I can set a custom permalink like:

    /index.php/%postname%/

    Is this a bug? Or something to do with the way Apache is set up?

    It’s too early for me to think that hard. :o)

    It was just the way it was years ago. I’m not a part of core anymore (retired) so I’ve been out of the loop for quite awhile.

    Glad everything worked out. Don’t forget to click resolved so we can close this thread.

    Thanks Stef. I appreciate the help. I’ve not run into this before. I’ll mark this one as resolved 🙂

    Anytime my friend, anytime.

    maykelboes

    (@maykelboes)

    @thebenkahn I got the same problem and this solution fixed it but now all the links have index.php inbetween them. I don’t want this. Is there a solution where I can keep /%postname%/ and a working restfull api?

    • This reply was modified 10 months ago by maykelboes.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘URL rewrites not working’ is closed to new replies.