Total failure to implement RewriteRule/ Cond!




Wordpress LScache Plugin: Total failure to implement RewriteRule/ Cond!

Last Updated on: Wed, 15 Apr 2026 00:00:02
AFter days of searching and trying everything I can think of to implement and test simple rewrite rules I need someones help! Im running WP on OpenLItespeed at Digital Ocean from their cloud image. The LS report number from my system is: WGMUNIIY My site is intended only for a small group of people and is running securely on SSL at https://photos.mencher.net/ I am trying to put in place 2 rulesets (to start with): 1) redirect all http to https and 2) prevent hotlinking to the images I show They dont seem to work at all. Although I thought I got the hotlink blocking working at one point, its not now. Ive tried putting the rewrite rules in the .htaccess and in the Virtual Host, both in the Rewrite section and in the Context section. Im aware that there are some slight differences in syntax betweeen the htaccess and the VH rules, but not entirely sure if I changed all of them. Ive done a graceful restart each time. Oddly, it seems that the LSCache is putting rules into the htaccess file (in a well-marked section) that, by your own documentation dont seem to work on OLS. The log file showed these messages amongst others: Rewrite directive: IfModule LiteSpeed bypassed. Invalid rewrite directive: CacheLookup on These rejected rules are from lines that have been added by the LScache module (according to the comment lines). Could it be that its expecting Apache instead of Litespeed Server? Or is the difference between OLS and the regular Litespeed syntax be causing this? Id be very grateful if anyone can tell me how to manage my htaccess cleanly and in harmony with the LSCache plug that makes its own changes! Id be a very happy camper if I could get at least those 2 rulesets above working without breaking anything else. Thanks in advance, Justin This topic was modified 3 years, 1 month ago by bzub. This topic was modified 3 years, 1 month ago by bzub. This topic was modified 3 years, 1 month ago by t-p. The page I need help with: http://photos.mencher.net/ Hi @bzub, OpenLiteSpeed require you to make specific setup on WebAdmin Console for loading the .htaccess, please check this instruction for more details. Thanks for the quick reply. I saw that article before and made sure the Auto load from htaccess option is set to Yes in the OLS Server configuration > General > Rewrite control section. Other things I have tried, that dont work: + putting one of the rewrite rules (as a test) in the virtual host under the Rewrite tab and making sure that Enable rewrite is Yes and Auto load from htacess is Yes + enabling the i) Server Rewrite alone ii) the VH rewrite alone + enabling a static context rewrite as per item 1 in this article: https://openlitespeed.org/kb/migrate-apache-rewrite-rules-to-openlitespeed/ None work. What in blazes am I doing wrong?!? Thanks again for your help with this! Update: I have tried implementing the following rules in the VH > Rewrite Rules section: RewriteRule ^/. .(log|ini)$ ? [F,L] # This WORKS- I get a 403 forbidden error when I try to access an .ini file in the site root directory as expected Neither of these work (I tried them separately): RewriteCond % SERVER_PORT 80 RewriteRule ^(. )$ https://% HTTP_HOST % REQUEST_URI [R=301,L] RewriteCond % SERVER_PORT 80 RewriteRule ^(. )$ https://photos.mencher.net/$1 [R,L] Going to http://photos.mencher.net/ gives me a 404 error INSTEAD of the expected redirect to https://photos.mencher.net/ Auto Load from .htaccess is Yes for at Server Configuration > General for all these cases. Hi, May I know did you restart OLS after you changed the rule ? Best regards, Yes. I have extravagantly and voluptuously pressed the graceful restart button each and every time a change was made. Sometimes twice. No luck ? those rules still dont work. Im very grateful for any insight you may have? Hi, You said 404 error? If you do not add any of these rules, you still have 404 error? Best regards, Yes, that is correct. I just tested removing all the directives from the .htacess file and from the VH Rewrite Rules section, doing a graceful restart and with no rules, I get the same 404 error. Ive noticed also that the 404 page looks like its still loading, even when the error page has been displayed. Could it be the syntax in the rules? Many thanks for your help qtrk. Hi, Could you please screenshot me one 404 page , how does it look like ? Best regards, THanks ? you should be able to see it on the actual link as given above: http://photos.mencher.net/ which should be redirected to https://photos.mencher.net/ ? but isnt. It looks like a standard Litespeed Server 404. Is there another reason you need an actual screenshot? I can try to find a file-sharing service if you do. I guess I cant post images here? Hi, I see now , as I suspected , 404 should be domain mapping issue OLS creates 2 listener , one on 80 port , another one on 443 port In such case, I believe 443 listener has domain mapped , where 80 port doesnt and then result in 404. Could you please login to OLS webadmin console , and check 80 port listener and its mapped domain ? Best regards, Yes! That did the trick! Thank you very much for your help. Thats awesome and Im so grateful to you! For anyone who has a similar problem, the Default Listener on port 80 wasnt mapped to anything so I did the following: -Open Litespeed Server Admin console -Listeners > Listener Name (choose listener for port 80 -click + to add a new Virtual Host Mapping -select the destination Virtual Host (where you want it to go) and for Domains enter for all domains unless you have a specific one you need to isolate -click Save and Graceful Restart That was not obvious from the startup guides I read and Im totally new to Litespeed Server. Thanks again and best wishes for the rest of your week! Hi, Glad to know it works now Best regards,



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference