Rewrite Rules

63 views
Skip to first unread message

Taffy

unread,
May 9, 2017, 7:36:50 PM5/9/17
to OpenLiteSpeed Development
Hi,

Is there any means to be able to add more Rewrite rules than seems to be possible from the GUI?  Even though the text field seems to accept limitless rules, rules at the end of the list stop functioning if the list becomes too long.

Thanks

David

unread,
May 10, 2017, 8:57:59 AM5/10/17
to Taffy, OpenLiteSpeed Development
Yes, we do.
You can use "RewriteFile" to load a file which has rewrite rules in it.
The format is
RewriteFile  /path/of/the/file


Thanks.
David
--
You received this message because you are subscribed to the Google Groups "OpenLiteSpeed Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openlitespeed-deve...@googlegroups.com.
To post to this group, send email to openlitespee...@googlegroups.com.
Visit this group at https://groups.google.com/group/openlitespeed-development.
For more options, visit https://groups.google.com/d/optout.

Taffy

unread,
May 10, 2017, 4:54:05 PM5/10/17
to OpenLiteSpeed Development
Thanks David.  Do these files have any size restrictions too?

Could be a good update for the GUI, enforce a character/line limit on the rules editor?  Could have saved me days of testing and research!

David

unread,
May 10, 2017, 5:11:21 PM5/10/17
to openlitespee...@googlegroups.com
We do not set any size limit for that file and also you can combine to use "RewriteFile"/"RewriteCond" and "RewriteRule", and also there can be more than one RewriteFile.

Thanks.
David


On 5/10/2017 4:54 PM, Taffy wrote:
Thanks David.  Do these files have any size restrictions too?

Could be a good update for the GUI, enforce a character/line limit on the rules editor?  Could have saved me days of testing and research!

Taffy

unread,
May 16, 2017, 9:32:18 PM5/16/17
to OpenLiteSpeed Development
Hi,

I can't seem to get this to work.  No matter where I put the file or what path I enter, the log always shows:

Error: Rewrite file [/home/user/rules/rules.txt ] can not open.

Am I missing something?  I can't find any documentation on the RewriteFile directive to check against.

Taffy

unread,
May 27, 2017, 1:38:39 AM5/27/17
to OpenLiteSpeed Development
Bump?

George Wang

unread,
May 28, 2017, 12:31:11 PM5/28/17
to openlitespee...@googlegroups.com


It is likely a problem with file system permission, the user that web server running as cannot read that file.
It could be directory along the path has strict permission mask.
you can try from command line

if OLS is running as nobody, you can try

sudo -u nobody cat /home/user/rules/rules.txt

also try
sudo -u nobody ls /home/user/rules/
sudo -u nobody ls /home/user

to find out which directory have permission problem.

Best regards,
George Wang

Taffy

unread,
May 30, 2017, 6:13:40 PM5/30/17
to OpenLiteSpeed Development
Hi George,

I've run the commands, there's no issues with permissions, I can cat the file contents as nobody.

What I have found after more testing:-

1. RewriteFile directive only works if it's the LAST directive in the GUI, otherwise I get the error about not being able to open the file.  This is no good when rules must be in a specific order.
2. I can only get it to fully work if I delete all rules from the GUI and place them in the file.

Not sure if this is the intended behaviour or not?

David

unread,
May 31, 2017, 3:33:04 PM5/31/17
to openlitespee...@googlegroups.com
There were two bugs in this case.
One is the when try to load the RewriteFile with \r at the end of the file path, it will cause 'can not open' problem.
Another is when RewriteFile is in the middle of the rules, it will be mess up and cause problem.
All of these two bugs were fixed and will be in the next release.
Thanks.
David

Taffy

unread,
May 31, 2017, 7:34:03 PM5/31/17
to OpenLiteSpeed Development
That's great, thanks David!
Reply all
Reply to author
Forward
0 new messages