WordPress OpenLitespeed Server 404 on any Link (pages, posts)

Spread the love

As I have been trying to move to litespeed server from apache, I have faced an issue with subroutes i.e. pages and posts. WordPress uses .htaccess for URL rewriting, but OpenLitespeed is not a drop-in replacement for Apache web server (yeah I know, it’s drop-in replacement for enterprise edition). So, after I tried updating .htaccess settings in WebAdmin of OpenLiteSpeed server i.e. to set the rewrite control to allow and autoload from .htaccess, it didn’t worked. So I had to copy the rules and pasted in the WebAdmin panel vhost -> Rewrite -> Rewrite Rules section. And everything worked as expected. Below are my pasted rules:

 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 RewriteBase /
 RewriteRule ^index.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]

And for HTTPS redirection you should add following lines at the top of the above rules:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/%{REQUEST_URI} [R,L]

And now everything is loading as expected!!!

But then I checked my .htaccess file again and noticed that there is an insertion of rules by a plugin. So I removed all the .htaccess file content and Deactivated all the plugins which have added the rules (generally plugins add comment to separate the rules). And then I saved the permalinks first and checked, everything was working fine, then I keep on enabling each plugin and checked the website (after updation of .htaccess, litespeed server needs to be gracefully restarted) and found the culprit. So, you have to check your .htaccess file rules as not all the rules are compatible with openlitespeed server.

Cheers and peace out.