Openlitespeed Wordpress pretty permalinks broken

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
I've enjoyed Openlitespeed since installing it on two of our Hosting servers.

However there are some quirks that are hard to figure out on wordpress.

Wordpress permalinks refuse to work even after re-setting them. They don't work for any of our wordpress sites hosted on our servers.
My error is similar to: https://www.litespeedtech.com/support/forum/threads/solved-403-forbidden.6189/
  • I've tried changing permalinks to just ugly links - these work fine.
  • Changing back to pretty permalinks just refuses to work.
  • I've tried every suggestion there is from a wordpress perspective including recreating the .htaccess file
I've tried some suggestions in the Openlitespeed forums. However most of this calls for using the openlitespeed pannel. Which is disabled in DirectAdmin. I've not found much in the line of documentation with regards to troubleshooting OpenLitespeed on Directadmin except for

2.On one of our Wordpress sites we get a 403 error for all images. I've checked permissions 775 Directories and 644 for files in wordpress' uploads folder.
I've tried

I've also been digging in the logs at /var/log/httpd
Found this error: "open_basedir restriction in effect. file is not within the allowed path" this seems to be related to images not showing on one of our sites in which I found this log entry over and over.

My conclusion for the first issue is that this must be something in Openlitespeed.

I'd appreciate if you have ideas that could help me get to the bottom of this.
 

jayw1

Verified User
Joined
Nov 20, 2019
Messages
126
Location
USA
I use OLS and had to ./build rewrite_confs - it worked just fine from that point.
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,934
Location
GMT +7.00
Every time you change .htaccess you will need to restart/reload OpenLiteSpeed. The OLS does read .htaccess files once only at a start time.

Permalinks are working fine with OLS, unless you have very custom redirects in .htaccess. By the way will you show what you have there in your .htaccess file?
 

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
@jayw1 thanks for that tip, I've tried it however it did not work in this case. But I'll be storing this for future use.

@zEitEr HTACCESS follows below. Note there are two examples from two different servers. Both run DirectAdmin Openlitespeed

This is what I have on a wordpress install that refuses to work with Pretty permalinks (seperate server to the .htaccess config below)


# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule ^min/\w+\.(css|js) - [E=cache-control:no-vary]
### marker CACHE RESOURCE start ###
RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
### marker CACHE RESOURCE end ###
### marker LOGIN COOKIE start ###
RewriteRule .? - [E="Cache-Vary:wp-postpass_482634203a69fbe7e6c8e5243d1a8425"]
### marker LOGIN COOKIE end ###
### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###
</IfModule>
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker MINIFY start ###
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} ^(.*)/min/(\w+)\.(css|js)$
RewriteCond %1/wp-content/cache/$2/$1.$2 -f
RewriteRule min/(\w+)\.(css|js) wp-content/cache/$2/$1.$2 [L]
</IfModule>
### marker MINIFY end ###
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<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


Wordpress install that shows no images.


# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule ^min/\w+\.(css|js) - [E=cache-control:no-vary]

### marker CACHE RESOURCE start ###
RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
### marker CACHE RESOURCE end ###

### marker LOGIN COOKIE start ###
RewriteRule .? - [E="Cache-Vary:wp-postpass_11b6bf7dfdd4438e252085f09af98128"]
### marker LOGIN COOKIE end ###

### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###

</IfModule>
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker MINIFY start ###
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} ^(.*)/min/(\w+)\.(css|js)$
RewriteCond %1/wp-content/cache/$2/$1.$2 -f
RewriteRule min/(\w+)\.(css|js) wp-content/cache/$2/$1.$2 [L]
</IfModule>
### marker MINIFY end ###

## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
# BEGIN optimizeMember GZIP exclusions
<IfModule rewrite_module>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (^|\?|&)optimizemember_file_download\=.+ [OR]
RewriteCond %{QUERY_STRING} (^|\?|&)no-gzip\=1
RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END optimizeMember GZIP exclusions
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<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
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,934
Location
GMT +7.00
Well, I don't have a wordpress with MINIFY plugin (I guess MINIFY is installed there) for testing yet. Kindly let me know is it sufficient to install MINIFY for this? Or should I install some more addons?
 

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
@zEitEr AFAIK the Minify section is part of the Litespeed Cache plugin.

Omitting that section does not change anything to the display of images though.

The following plugins are installed for this site that does not show any images:
  • Antispam Bee
  • Force Regenerate Thumbnails
  • LiteSpeed Cache
  • Loginizer
  • OptimizeBuilder
  • Really Simple SSL
  • Velvet Blues Update URL's
I've also spinned up a brand new install of Wordpress on the server where permalinks are broken on most Wordpress installs
It's over at mybackupvault.co.za if you're keen to have a look. Its a vanilla Wordpress install and has no custom plugins or custom themes.


Here's its .htaccess

# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<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
 

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
I've restarted Openlitespeed several times. I've used vanilla wordpress installations and still get the same issue with permalinks broken out of the box.

Since my last update I also added a cron entry to restart openlitespeed when changes to .htaccess files are detected.

Digging in the logs also turned up nothing yet. Anyone know where else I can look for a clue?
 

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
Ok so I solved the issue with Images not showing. It was an .htaccess issue afterall

I dropped most of the unneeded bits in .htaccess

Also looked into this line:
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]

Which disables hotlinking. Essentially this blocked any access to images on the Wordpress site. May have been put there by a plugin.
 

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
Well, I don't have a wordpress with MINIFY plugin (I guess MINIFY is installed there) for testing yet. Kindly let me know is it sufficient to install MINIFY for this? Or should I install some more addons?
So about Symlinks broken on the server's Wordpress Installs. I've rebuilt configs

Some digging shows that Comodo Mod Security rules I've added are missing files. After rebuilding configs threw an error about the files not existing. I've removed this for now.

I'm puzzled. I've dug into wordpress configs and flushed Wordpress cache with WP-CLI and frontend tools. I've ruled out .htaccess errors.

It seems the issue is OLS here. I've been having trouble with this for a while and it's annoying and bad for SEO.
I think OLS is very stable all things considered. However I'm not sure where to dig to resolve this.
 

jayw1

Verified User
Joined
Nov 20, 2019
Messages
126
Location
USA
I think OLS is very stable all things considered. However I'm not sure where to dig to resolve this.
Have you customized any of the OLS config files? Out of the box, WordPress works just fine for me.
I suspect something is wrong with your WP setup somewhere. Disabling all plugins and restarting OLS is a good place to start. Rename the plugins folder temporarily in /wp-config/
 

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
Have you customized any of the OLS config files? Out of the box, WordPress works just fine for me.
I suspect something is wrong with your WP setup somewhere. Disabling all plugins and restarting OLS is a good place to start. Rename the plugins folder temporarily in /wp-config/
Thanks for your input Jayw1

The OLS Config has not been changed on this box since installation. The defaults are pretty sane and have worked well for us.

I also thought of Plugins first. But after extensive WordPress troubleshooting I'm convinced the issue is elsewhere.
So to prove my hunch I installed another Wordpress site on an unused domain in the same DirectAdmin user account.

This install has no active plugins. It contains a Vanilla Wordpress setup including the standard .htaccess that generates after installing:

# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<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

.htaccess permissions are 644 as are all files. And directory Permissions are 755
But it still malfunctions. This has lead me to believe that this issue is not related to WordPress per say.

I've restarted OLS several times and also have a cron setup for when WordPress makes changes.

If I enable /?page_id=2 type links everything works fine.

What's very odd is that of the two OLS boxes I run I only have this issue on one of them. This also lead me to believe that it must be Wordpress at first. This issue has had me scratching my head for the past 2months.
 

jayw1

Verified User
Joined
Nov 20, 2019
Messages
126
Location
USA
Are all of the permalink structures broken? I am using "Post Name".
 

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
Yes seems like all of them are dead. I've also used "Post Name" and just tried "Year Month Day"
 

jayw1

Verified User
Joined
Nov 20, 2019
Messages
126
Location
USA
Yes seems like all of them are dead. I've also used "Post Name" and just tried "Year Month Day"
So strange. There's nothing in DA under Server Manager > Custom HTTPD Configurations > openlitespeed.conf > Customize either?
You'll see the OLS config file for each domain there as well, perhaps post one where pretty links are broken.
Ensure these lines are present:

Code:
  rewrite  {
    enable                  1
    autoLoadHtaccess        1
  }
and be sure to run service lsws restart as well.
 

codes9

Verified User
Joined
Sep 5, 2019
Messages
15
Thanks for your recommendation that was a fruitful search. I could not edit the files in question from DirectAdmin directly but went to /usr/local/directadmin/data/users/

I found the following:

rewrite {
enable 1
autoLoadHtaccess 1
RewriteCond %{HTTP:X-Forwarded-Proto} https [NC]
RewriteRule . - [E=HTTPS:eek:n]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
}

I removed everything but the lines you mentioned and restarted OLS.
Found an error again that I've been working on

After resolving this I no longer get OLS 404 pages but Wordpress 404 pages.

From what I can see the lines I removed redirect pages to HTTPS so I wonder if the other error is underlying

Also notice a mod security error (not finding the Comodo Firewall files - although installed) I've disabled mod security as well to get rid of that error

So looks like I'm one step closer
 
Top