Welcome! Log In Create A New Profile

Advanced

How to convert to nginx

Posted by minhte 
How to convert to nginx
February 23, 2012 01:03PM
Hello,

I moved from apache to nginx. But rewrite doesn't work. Please tell me how to convert below rewrite rules to nginx:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteCond %{QUERY_STRING} SELECT(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} UNION(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} UPDATE(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteRule ^(.*)$ index.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>



Thanks.
Re: How to convert to nginx
February 24, 2012 03:46PM
Finally it works for me:

if ($args ~ "base64_encode.*(.*)"){
set $rule_0 1;
}
if ($args ~* "(<|%3C).*script.*(>|%3E)"){
set $rule_0 1;
}
if ($args ~ "GLOBALS(=|[|%[0-9A-Z]{0,2})"){
set $rule_0 1;
}
if ($args ~ "_REQUEST(=|[|%[0-9A-Z]{0,2})"){
set $rule_0 1;
}
if ($args ~ "SELECT(=|[|%[0-9A-Z]{0,2})"){
set $rule_0 1;
}
if ($args ~ "UNION(=|[|%[0-9A-Z]{0,2})"){
set $rule_0 1;
}
if ($args ~ "UPDATE(=|[|%[0-9A-Z]{0,2})"){
set $rule_0 1;
}
if ($rule_0 = "1"){
rewrite ^/(.*)$ /index.php last;
}
if (!-f $request_filename){
set $rule_1 1$rule_1;
}
if (!-d $request_filename){
set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 276
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