about rewrite rule

Igor Sysoev is at rambler-co.ru
Thu Mar 5 08:44:15 MSK 2009


On Thu, Mar 05, 2009 at 01:38:45PM +0800, Weibin Yao wrote:

> These are rewrite rules for apache:
> 
> RewriteBase /
> RewriteCond %{REQUEST_URI}    !\.(gif|jpeg|png|jpg|bmp)$
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule . index.php [L]
> 
> How to change these rules for nginx?

If you use FastCGI and nginx 0.7.x:

location / {
    try_files      $uri  $uri/  @php;
}

location ~ \.(gif|jpe?g|png|bmp)$ {
}

location @php {
    fastcgi_pass   ...;

    fastcgi_param  SCRIPT_FILENAME  /path/to/index.php;

    ... other fastcgi_param
}


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list