[Solved] regex length for $HTTP["url"] =~
Added by pluffmud 10 months ago
lighttpd 1.4.59-1+deb11u2 arm64
I have it working but when I try to add all my possible urls into the "$HTTP["url"] =~" regex pattern the server wont start if this pattern is greater than 141 characters (or so).
I'm sure there is a better way to do this but I just started with lighttpd this week .
This works
$HTTP["url"] =~ "^/docs($|/)|/Downloads($|/)|/Pictures($|/)|/MacPics($|/)|/IpadPicsBackup($|/)|/MacBookPro($|/)|/Backup-tootie($|/)|/openwrts($|/)|/Win10($|/)"
this does not
$HTTP["url"] =~ "^/docs($|/)|/Downloads($|/)|/Pictures($|/)|/MacPics($|/)|/IpadPicsBackup($|/)|/MacBookPro($|/)|/Backup-tootie($|/)|/openwrts($|/)|/Win10($|/)|/Win11($|/)"
Replies (4)
RE: regex length for $HTTP["url"] =~ - Added by gstrauss 10 months ago
I'm sure there is a better way to do this but I just started with lighttpd this week .
You seem to be new to a lot of things.
Carefully read all of How to get support - please read
Carefully read the error message that lighttpd gives to your configuration.2023-12-01 11:31:09: (data_config.c.116) Too many captures in regex, use (?:...) instead of (...): ^/docs($|/)|/Downloads($|/)|/Pictures($|/)|/MacPics($|/)|/IpadPicsBackup($|/)|/MacBookPro($|/)|/Backup-tootie($|/)|/openwrts($|/)|/Win10($|/)|/Win11($|/)
Try harder to solve some of your own problems before posting.
mod_rewrite contains a link to those who do not know how to write regular expressions.
https://www.regular-expressions.info/
Regular expressions are used by lighttpd but are independent of lighttpd. Regular expressions were created a long, long time ago.
https://en.wikipedia.org/wiki/Regular_expression
lighttpd 1.4.69 is available from bullseye-backports, so I suggest you upgrade before posting any questions about something else not working that was fixed in the 2 years between releases of lighttpd 1.4.59 and lighttpd 1.4.69.
RE: regex length for $HTTP["url"] =~ - Added by pluffmud 10 months ago
I changed it to
"^/(docs|Downloads|Pictures|MacPics|IpadPicsBackup|MacBookPro|Backup-tootie|openwrts|Win(10|11))($|/)"
and it works yet I still think there must be a better way
RE: [Solved] regex length for $HTTP["url"] =~ - Added by gstrauss 10 months ago
You used regex alternation and now have a working solution. Good.
yet I still think there must be a better way
Read the links provided and think about what they teach.
There are lots of different and better ways to solve different problems.
Carefully read all of How to get support - please read
RE: [Solved] regex length for $HTTP["url"] =~ - Added by gstrauss 10 months ago
Since you seem to have missed reading the error message even after being reminded to read the error message:
The error message already provided a better solution: Too many captures in regex, use (?:...) instead of (...)