Welcome! Log In Create A New Profile

Advanced

Converting apache rewrite rules to nginx again

Posted by pixelfields 
Converting apache rewrite rules to nginx again
July 25, 2012 10:23AM
Hi,
please can anybody help me with converting following apache rewrite rules to nginx?

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.* - [L]

RewriteRule ^(.*)\.ajax?$ ajax.php?module=$1 [L,QSA]
RewriteRule ^(.*)\.form?$ form.php?module=$1 [L,QSA]
RewriteRule ^(.*)\/(stranka-[0-9-]+)?$ $1?p=$2 [L,QSA]
RewriteRule ^download\/([a-zA-Z0-9-_.]+)?$ download.php?file=$1 [L,QSA]
RewriteRule ^([a-z0-9-]+)\/([a-z0-9_-]+)\/([a-zA-Z0-9_-]+)?$ index.php?page=$1&subpage=$2&cid=$3 [L,QSA]
RewriteRule ^([a-z0-9-]+)\/([a-z0-9_-]+)?$ index.php?page=$1&subpage=$2 [L,QSA]
RewriteRule ^([a-z0-9-]+)?$ index.php?page=$1 [L,QSA]

Thanks too much.

Dusan Simek
Re: Converting apache rewrite rules to nginx again
July 26, 2012 04:44AM
Couldn't test...

location / {
if (-e $request_filename){
rewrite ^/(.*)\.ajax?$ /ajax.php?module=$1 break;
}

rewrite ^/(.*)\.form?$ /form.php?module=$1 break;
rewrite ^/(.*)\/(stranka-[0-9-]+)?$ /$1?p=$2 break;
rewrite ^/([a-z0-9-]+)\/([a-z0-9_-]+)\/([a-zA-Z0-9_-]+)?$ /index.php?page=$1&subpage=$2&cid=$3 break;
rewrite ^/([a-z0-9-]+)\/([a-z0-9_-]+)?$ /index.php?page=$1&subpage=$2 break;
rewrite ^/([a-z0-9-]+)?$ /index.php?page=$1 break;
}

location /download {
rewrite ^/download\/([a-zA-Z0-9-_.]+)?$ /download.php?file=$1 break;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 289
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready