rewrite rules

Cliff Wells cliff at develix.com
Mon Jun 1 11:30:26 MSD 2009


On Mon, 2009-06-01 at 07:30 +0200, Tomasz Pajor wrote:
> Hello,
> 
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} -s [OR]
> RewriteCond %{REQUEST_FILENAME} -l [OR]
> RewriteCond %{REQUEST_FILENAME} -d
> RewriteRule ^.*$ - [NC,L]
> RewriteRule ^.*$ index.php [NC,L]
> 
> Can anybody point me out how should this rules look like for nginx, 
> thanks in advance!

I don't think you'll need any rewrites in Nginx.  It appears that the
above basically says, "if the file exists, serve it, otherwise hand the
request to PHP".  In Nginx that equates to:

location / {
    root /path/to/docroot;
    expires 30d;
    index index.php;
    error_page 404 = index.php; 
    log_not_found off;
}

location \.php$ {
    # ... usual PHP FastCGI stuff
}

Regards,
Cliff






More information about the nginx mailing list