Rewrite rule for nginx from Apache

Igor Sysoev igor at sysoev.ru
Fri May 20 15:19:52 MSD 2011


On Wed, May 18, 2011 at 10:52:39PM -0400, ltss wrote:
> Hello i am new to nginx and i need some help to convert my .htaccess, i
> have tried some shit but that not work ...
> 
> 	Options FollowSymLinks
> 	RewriteEngine On
> 
> 	RewriteRule ^(.*)\.php/img/(.*)$ img/$2 [C]
> 	RewriteRule ^/img/(.*)$ img/$2 [QSA,L]
> 
> 	RewriteCond %{REQUEST_FILENAME} !^scriptsFtp.*$
> 
> 	RewriteCond %{REQUEST_FILENAME} !-d
> 	RewriteCond %{REQUEST_FILENAME} !-f
> 		RewriteRule ^(.*)$ index.php [QSA,L]

It's not easy to understand what these .htaccess should do.
Probably this:

root  /path/to/files;

location / {
   try_files  $uri  $uri/  /index.php?$args;
}

location /scriptsFtp {
   ...
}

location ~ ^(.*)\.php/img/(.*)$ {
   alias  /path/to/img/$2;
}

location ~ .php$ {
   fastcgi_pass   ...
   ...
}


-- 
Igor Sysoev



More information about the nginx mailing list