Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im migrating an apache2 server to Lighttpd, however im having some issues with Mod_Rewrite.

I have a directory /api/, which I need to exclude from the rewriting rules as follows:

url.rewrite-once = (
    ".*\?(.*)$" => "/index.php?$1",
    ".*\.(js|ico|gif|jpg|png|css)$" => "$0",
    "" => "/index.php"

I have tried to surround the block with

$HTTP["url"] !~ "^/api/" { }

However this has no effect and just excludes every URL from rewriting. Does anyone know of a way to

a) Exclude /api/ from the rewriting

b) exclude every actual directory present on the server from rewriting

I have seen Lua scripts for Drupal that can do the latter, however im not proficient in Lua and do not know how to configure this for a Zend Framework application.

Entire Configuration:


share|improve this question

Change the first part:

".*\?(.*)$"             => "/index.php?$1",

to "^/(?!api[/]).*\?(.*)$" or "^/(?!api(?:$|/)).*\?(.*)$"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.