I'm trying hard to make my code work on nginx. This configuration works with lighttpd but I want migrate it to nginx.
Rewrite rules on lighttd :
url.rewrite-once = (
"^/(ui)/(.*)$" => "/gi.php/$1/$2",
"/(.*)\.(.*)" => "$0",
"/(xhr|js-api)/(.*)" => "$0",
"^/([^.]+)$" => "/gi.php/$1"
)
Can anyone help in this conversion? I tried using lot of things, including converting it to apache rewrite rules, but none of them worked.
Nginx rule:
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/(.*)$ /gi.php/$1 last;
}
Error : 404
Any suggestions?
Best Answer
You don't generally do rewrites in nginx, the same way you do them in Apache or lighttpd. Most such things should be replaced with
try_files
instead.A trivial example:
See the nginx documentation for more details.