我如何重写此 URL:
mysite.com/folder1/file.php?kw=KEYWORD
到
mysite.com/folder1/file/KEYWORD
和
mysite.com/folder1/single.php?sname=hoover-firestarter-freemusic&vid=EawzHfX4n30
进入
mysite.com/folder1/single/hoover-firestarter-freemusic
请帮助我,提前谢谢大家!
答案1
就是这样:
location ~* ^/([a-z0-9]+)/([a-z0-9]+)\.php$ {
if ($arg_kw) {
return 302 $scheme://$server_name/$1/$2/$arg_kw;
}
if ($arg_sname) {
return 302 $scheme://$server_name/$1/$2/$arg_sname;
}
}