Welcome! Log In Create A New Profile

Advanced

lighttpd rewrite rule to nginx, not working

Posted by WisdomFusion 
lighttpd rewrite rule to nginx, not working
March 28, 2010 10:25PM
Hi, all

Last night, I had changed my webserver form lighty to nginx, the following code is the rewrite rules in lighttpd.conf:
[code]
url.rewrite = (

"/index\.asp" => "/index.php",
"/index\.asp\?boardid=([0-9]+)$" => "/forum-$1-1.html",
"/index\.asp\?boardid=([0-9]+)(.*)$" => "/forum-$1-1.html",
"/index_([0-9]+)(.*)$" => "/forum-$1-1.html",
"/dispbbs\.asp\?boardID=([0-9]+)&ID=([0-9]+)(.*)$" => "/thread-$2-1-1.html",

"^(.*)/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)_([0-9]+)_([0-9]+)\.html$" => "$1/thread-$4-1-1.html",
"^(.*)/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)_([0-9]+)\.html$" => "$1/thread-$4-1-1.html",
"^(.*)/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)\.html$" => "$1/thread-$4-1-1.html",
"^(.*)/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)\.html$" => "$1/thread-$3-1-1.html",
"^(.*)/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_(\w+)\.html$" => "$1/thread-$3-1-1.html",
"^(.*)/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)\.html$" => "$1/thread-$3-1-1.html",
"^(.*)/dispbbs_([0-9]+)_([0-9]+)(.+)*\.html$" => "$1/thread-$3-1-1.html",
"^(.*)/dispbbs_([0-9]+)_([0-9]+)\.html$" => "$1/thread-$3-1-1.html",

"/dv_rss_(.+)_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)_count([0-9]+)\.html" => "/archiver/tid-$2.html",
"/dv_rss_(.+)_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)\.html" => "/archiver/tid-$2.html",
"/dv_rss_(.+)_([0-9]+)_([0-9]+)_([0-9]+)\.html" => "/archiver/tid-$2.html",
"/dv_rss_(.+)_([0-9]+)_([0-9]+)_count([0-9]+)\.html" => "/forum-$2-1.html",
"/dv_rss_(.+)_([0-9]+)_([0-9]+)\.html" => "/forum-$2-1.html",
"/dv_rss_(.+)_([0-9]+)\.html" => "/forum-$2-1.html",
"/dv_rss(.+)*\.html" => "/archiver/",

"/UploadFile/(.*)" => "/index.php",
"/dispbbs\.asp\?(.*)&id=([0-9]+)(.*)" => "/thread-$2-1-1.html",
"/dispuser\.asp\?id=([0-9]+)(.*)" => "/space-uid-$1.html",
"/dv_rss\.asp\?(.*)&id=([0-9]+)(.*)" => "/archiver/tid-$2.html",
"/dv_rss\.asp\?(.*)boardid=([0-9]+)(.*)" => "/archiver/fid-$2.html",
"/dv_rss\.asp\?s=xml" => "/rss.php",
"/dv_rss\.asp(.*)" => "/archiver/"

)
[/code]

In nginx, I put the following rules in the nginx.conf,

[code]
rewrite "/index\.asp" "/index.php" last;
rewrite "/index\.asp\?boardid=([0-9]+)$" "/forum-$1-1.html" last;
rewrite "/index\.asp\?boardid=([0-9]+)(.*)$" "/forum-$1-1.html" last;
rewrite "/index_([0-9]+)(.*)$" "/forum-$1-1.html" last;
rewrite "^/dispbbs\.asp\?boardID=([0-9]+)&ID=([0-9]+).*$" "/thread-$2-1-1.html" last;

rewrite "/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)_([0-9]+)_([0-9]+)\.html$" "$1/thread-$3-1-1.html" last;
rewrite "/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)_([0-9]+)\.html$" "$1/thread-$3-1-1.html" last;
rewrite "/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)\.html$" "$1/thread-$3-1-1.html" last;
rewrite "/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)\.html$" "$1/thread-$2-1-1.html" last;
rewrite "/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_(\w+)\.html$" "$1/thread-$2-1-1.html" last;
rewrite "/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)\.html$" "$1/thread-$2-1-1.html" last;
rewrite "/dispbbs_([0-9]+)_([0-9]+)(.+)*\.html$" "$1/thread-$2-1-1.html" last;
rewrite "/dispbbs_([0-9]+)_([0-9]+)\.html$" "$1/thread-$2-1-1.html" last;

rewrite "/dv_rss_(.+)_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)_count([0-9]+)\.html" "/archiver/tid-$2.html" last;
rewrite "/dv_rss_(.+)_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)\.html" "/archiver/tid-$2.html" last;
rewrite "/dv_rss_(.+)_([0-9]+)_([0-9]+)_([0-9]+)\.html" "/archiver/tid-$2.html" last;
rewrite "/dv_rss_(.+)_([0-9]+)_([0-9]+)_count([0-9]+)\.html" "/forum-$2-1.html" last;
rewrite "/dv_rss_(.+)_([0-9]+)_([0-9]+)\.html" "/forum-$2-1.html" last;
rewrite "/dv_rss_(.+)_([0-9]+)\.html" "/forum-$2-1.html" last;
rewrite "/dv_rss(.+)*\.html" "/archiver/" last;

rewrite "/UploadFile/(.*)" "/index.php" last;
rewrite "/dispbbs\.asp\?(.*)&id=([0-9]+)(.*)" "/thread-$2-1-1.html" last;
rewrite "/dispuser\.asp\?id=([0-9]+)(.*)" "/space-uid-$1.html" last;
rewrite "/dv_rss\.asp\?(.*)&id=([0-9]+)(.*)" "/archiver/tid-$2.html" last;
rewrite "/dv_rss\.asp\?(.*)boardid=([0-9]+)(.*)" "/archiver/fid-$2.html" last;
rewrite "/dv_rss\.asp\?s=xml" "/rss.php" last;
rewrite "/dv_rss\.asp(.*)" "/archiver/" last;
[/code]
unfortunately, it is not working.

Is there any problem?

thanks,

gaivn
Re: lighttpd rewrite rule to nginx, not working
March 29, 2010 12:31AM
Most nginx rewrites will begin with a caret (^). Also, generally, quotes are not necessary unless you are using curly braces as they have special meaning in nginx configuration files.

For the first line try

rewrite ^/index\.asp /index.php last;

and so on. I am not an expert in lighttpd rewrites but that would be a good place to start.

--
Jim Ohlstein
Re: lighttpd rewrite rule to nginx, not working
March 29, 2010 01:22AM
thx for ur quick reply,

i have try your advice,

[code]
rewrite ^/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)_([0-9]+)_([0-9]+)\.html$ /thread-$3-1-1.html last;
rewrite ^/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)_([0-9]+)\.html$ /thread-$3-1-1.html last;
rewrite ^/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_skin([0-9]+)\.html$ /thread-$3-1-1.html last;
rewrite ^/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)\.html$ /thread-$2-1-1.html last;
rewrite ^/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)_(\w+)\.html$ /thread-$2-1-1.html last;
rewrite ^/dispbbs_([0-9]+)_([0-9]+)_([0-9]+)\.html$ /thread-$2-1-1.html last;
rewrite ^/dispbbs_([0-9]+)_([0-9]+)(.+)*\.html$ /thread-$2-1-1.html last;
rewrite ^/dispbbs_([0-9]+)_([0-9]+)\.html$ /thread-$2-1-1.html last;
[/code]


rules abave works now, however, the following are still dead,
[code]
rewrite ^/index\.asp /index.php last;
rewrite ^/index\.asp\?boardid=([0-9]+)$ /forum-$1-1.html last;
rewrite ^/index\.asp\?boardid=([0-9]+)(.*)$ /forum-$1-1.html last;
rewrite ^/index_([0-9]+)(.*)$ /forum-$1-1.html last;
rewrite ^/dispbbs\.asp\?boardID=([0-9]+)&ID=([0-9]+)$ /thread-$2-1-1.html last;
[/code]
Re: lighttpd rewrite rule to nginx, not working
March 29, 2010 03:05AM
i have add $ to each rule, however, it does not work either....

[code]
rewrite ^/dispbbs\.asp\?boardID=([0-9]+)&ID=([0-9]+).*$ /thread-$2-1-1.html last;
rewrite ^/dispbbs\.asp\?(.*)&id=([0-9]+)(.*)$ /thread-$2-1-1.html last;
rewrite ^/index\.asp\?boardid=([0-9]+)(.*)$ /forum-$1-1.html last;
rewrite ^/index\.asp\?boardid=([0-9]+)$ /forum-$1-1.html last;
rewrite ^/index\.asp$ /index.php last;
[/code]
Re: lighttpd rewrite rule to nginx, not working
March 29, 2010 09:09PM
Jim Ohlstein Wrote:
-------------------------------------------------------
> Most nginx rewrites will begin with a caret (^).
> Also, generally, quotes are not necessary unless
> you are using curly braces as they have special
> meaning in nginx configuration files.
>
> For the first line try
>
> rewrite ^/index\.asp /index.php last;
>
> and so on. I am not an expert in lighttpd rewrites
> but that would be a good place to start.

This rule works,
[code]
rewrite ^/index_([0-9]+)(.*)$ /forum-$1-1.html last;
[/code]

And I change the rest to,
[code]
location /index.asp {
if ($arg_boardid ~ "^([0-9]+)") {
rewrite ^ /forum-$arg_boardid-1.html break;
}
rewrite ^ /index.php break;
}
location /dispbbs.asp {
rewrite ^ /thread-$arg_id-1-1.html break;
}
[/code]
But, it still does not work.

V/R,

gavin
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 103
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready