Search code examples
phpregexlighttpd

Lighttpd url rewrite with php mvc


I wish to reroute all requests on root/cvideo/... to root/cvideo/index.php, the problem comes on js and css which also get routed, this is the best I can do...

url.rewrite-once = ( "/(js|jpg|css|)/$"=>"$0",
                     "^/cvideo([^?])*$"=>"/cvideo/index.php" )

My regex seems regit but it result in a 404 error whenever I access a js or css file, other parts works fine. Help? Please?


Solution

  • Your regex pattern is a bit wrong:

    url.rewrite-once = (
        "^.*\.(js|jpg|css)/?$" => "$0",
        "^/cvideo" => "/cvideo/index.php"
    );
    

    Do note that, I'm unaware of how lighttpd handles $0 groups, which is why I've added the .* in pattern.