Need help convert apache rewrite rules to nginx

Edho Arief edho at myconan.net
Sun Nov 25 06:51:09 UTC 2012


2012/11/25 Nerijus Skaržauskas <nerijus.skarzauskas at gmail.com>:
> Hello,
> need help with convert apache rewrite rules to nginx. My .htaccess:
>
>
> RewriteEngine on
> RewriteBase /
> ErrorDocument 404 /
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule ^naujienos+ news.php/$1 [L]
> RewriteRule     ^skelbimai/?$   index.php?p=20 [nc]
> RewriteRule     ^skelbimai?$    index.php?p=20 [nc]
> RewriteRule     ^reklama_svetaineje/?$  index.php?p=25 [nc]
> RewriteRule     ^reklama_svetaineje?$   index.php?p=25 [nc]
> RewriteRule     ^reklama_laikrastyje/?$ index.php?p=15 [nc]
> RewriteRule     ^reklama_laikrastyje?$  index.php?p=15 [nc]
> RewriteRule     ^prenumeratos_uzsakymas/?$      /prenumerata.php [nc]
> RewriteRule     ^prenumeratos_uzsakymas?$       /prenumerata.php [nc]
> RewriteRule     ^newprenum/?$   /pren_all.php [nc]
> RewriteRule     ^newprenum?$    /pren_all.php [nc]
> RewriteRule     ^negaunantiems_laiku/?$ index.php?p=24 [nc]
> RewriteRule     ^negaunantiems_laiku?$  index.php?p=24 [nc]
> RewriteRule     ^naujienos/p(.*)$       /news.php?pg=$1 [nc]
> RewriteRule     ^naujienos/?$   /news.php [nc]
> RewriteRule     ^naujienos?$    /news.php [nc]
> RewriteRule     ^lics/?$        /Lics.php [nc]
> RewriteRule     ^lics?$ /Lics.php [nc]
> RewriteRule     ^kontaktai/?$   index.php?p=18 [nc]
> RewriteRule     ^kontaktai?$    index.php?p=18 [nc]
> RewriteRule     ^atsisiusk_dienrasti/?$ /newspaper.php [nc]
> RewriteRule     ^atsisiusk_dienrasti?$  /newspaper.php [nc]
> RewriteRule     ^apie_leidejus/?$       /leidejai.php [nc]
> RewriteRule     ^apie_leidejus?$        /leidejai.php [nc]
> RewriteRule     ^akcijos/?$     index.php?p=13 [nc]
> RewriteRule     ^akcijos?$      index.php?p=13 [nc]
>
>
>

error_page 404 /;
try_files $uri $uri/ @rewrites;

location @rewrites {
 ...<left as exercise>...
}



More information about the nginx mailing list