views:

39

answers:

2

I am trying to match any url that has /images/ , /styles/ , or /scripts/ in a lighttpd $HTTP["url"] statement. How could this be done? I am currently using "^/images/" , etc. and it's only working if that directory is in the beginning of the URL.

A: 

"/images/|/styles/|/scripts/"

Alexandr Ciornii
A: 
/(images|styles|scripts)/

will match any string that has either /images/, /styles/ or /scripts/ in it.

Since you need to match the slash, use a different regex delimiter, e. g. !:

if ($subject =~ m!/(images|styles|scripts)/!) {
    # Successful match
} else {
    # Match attempt failed
}
Tim Pietzcker