Question

LiteSpeed Server returning 404 for Posts, Pages, & Categories. Home is working!

Hello,

I’m using OpenLitespeed Wordpress on Digital Ocean droplet. I was able to access my blog but now I’m getting 404 for all post and pages except the Homepage.

When I set permalink to plain, everything seems to be working. But when I choose to put post-name as permalink, I’m getting 404 error.

When I check wordpress health, it is showing that ‘the rest api encountered an unexpected result litespeed server’.

And also, https://site.com/wp-json/wp/v2/posts/ when I access this path with my site, I get a 404.

Kindly let me know the solution for this issue. TIA.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
May 18, 2023

Hey @triber9999,

I think the issues you’re experiencing are related to how OpenLiteSpeed (OLS) manages rewrite rules.

WordPress pretty permalinks require these rules to function correctly. When permalinks are set to “plain,” they do not rely on rewrite rules, hence they work fine. When you switch to “post name,” they do require these rules, which appear to be not functioning correctly.

Enable rewrite rules in OpenLiteSpeed: Go to the OpenLiteSpeed WebAdmin console, navigate to Virtual Hosts > Rewrite > Rewrite Control, and ensure that Rewrite is set to Enable.

Manually refresh the rewrite rules: In your WordPress admin area, navigate to Settings > Permalinks and click Save Changes without modifying anything. This will force WordPress to flush its rewrite rules and regenerate them.

Hi,

Please try to restart web server with the following command after changing the permalink, and let us know if it fixes the issue for you.

systemctl restart lsws

The restart won’t cause any downtime to the site by the way.

Best, Eric

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel