Apche rewrite rule convert to nginx

Discussion in 'Server Operation' started by nerijussk, Nov 24, 2012.

  1. nerijussk

    nerijussk New Member

    Hello,
    please help me converte apache rewrite rule to nginx:

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^naujienos+ news.php/$1 [L]
    RewriteRule ^naujienos/p(.*)$ /news.php?pg=$1 [nc]
    RewriteRule ^naujienos/?$ /news.php [nc]
    RewriteRule ^naujienos?$ /news.php [nc]
     
  2. falko

    falko Super Moderator

  3. nerijussk

    nerijussk New Member

    yes but does not work
     
  4. falko

    falko Super Moderator

    Try

    Code:
    if (!-e $request_filename){ 
      rewrite ^/naujienos+ /news.php/$1 break; 
    }
    rewrite ^/naujienos/p(.*)$ /news.php?pg=$1; 
    rewrite ^/naujienos/?$ /news.php; 
    rewrite ^/naujienos?$ /news.php;
     

Share This Page