if $request_uri [not static file], then ...

cynix cynix at cynix.org
Sat Nov 8 09:38:41 MSK 2008


Joe Aston <joe at ...> writes:

> 
> How can I achieve the following?
> 
> I want to redirect all non-file requests to a script, like this:
> 
>           if ($request_uri !~* (js|css|images|etc)$) {
>             rewrite ^/(.+)$ /index.php?q=$1 last;
>             break;
>           }
> 
> ...but this does not work. I do not want to use "if (!-f
> $request_filename)" to avoid disk overhead.
> 
> Can anyone make a suggestion?
> 
> Thanks!
> 
> 

location / {
 error_page 404 = @handler;
 log_not_found off;
}

location @handler {
 fastcgi_pass 127.0.0.1:1234;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root/index.php;
 fastcgi_param QUERY_STRING q=$request_uri&$query_string;
}






More information about the nginx mailing list