How could I permanently redirect dynamic url with querystrings?

WisdomFusion nginx-forum at nginx.us
Sat Jun 19 17:53:32 MSD 2010


Hi, all

I recently migrates my web server from lighty to nginx(nginx/0.7.67 +
php-fpm), but there is something strange with the nginx rewrite rule.


The problem is, I wanna direct rules like this,

http://www1.example.com/dispbbs.asp?boardID=15&ID=164752

to a new domain([b]www2[/b]) and new format as follows,

http://www2.example.com/thread-164752-1-1.html


However, I gets some strange results,
[code]
http://www2.example.com/thread-164752-1-1.html?boardID=15&ID=164752
[/code]

Why? Why does the querystring '[b]?boardID=15&ID=164752[/b]' still
appears and so strange?


Here is my settings in nginx.conf
[code]
...

#rewrite dynamic url with querystrings
if ($args ~* "boardid=[0-9]+&id=([0-9]+)") {
  set $tid $1;
  rewrite ^.*$ http://www2.example.com/thread-$tid-1-1.html permanent;
}
...
#here, i put some rewrite rules#
...
#at the end, rewrite undefined urls permanently
rewrite ^(.*) http://www2.example.com$1 permanent;
...
[/code]



V/R,
gavin

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,100268,100268#msg-100268




More information about the nginx mailing list