正确的nginx重写规则
如何使用nginx重写规则进行转换 example.com/?subtopic=forum&action=show\u board&id=1 进入这个 example.com/forum/board/1 还是这个 example.com/?subtopic=characters&name=external 进入这个 example.com/characters/external 我已经找到并尝试使用此代码正确的nginx重写规则,nginx,rewrite,Nginx,Rewrite,如何使用nginx重写规则进行转换 example.com/?subtopic=forum&action=show\u board&id=1 进入这个 example.com/forum/board/1 还是这个 example.com/?subtopic=characters&name=external 进入这个 example.com/characters/external 我已经找到并尝试使用此代码 location / { rewrite ^/subtopic/(
location / {
rewrite ^/subtopic/(.*)$ /?subtopic=$1 last;
}
但是它不起作用(我真的是一个重写新手)你可以试试这些规则:
rewrite /(.*)/(.*)/(\d+) /?subtopic=$1&action=show_$2&id=$3 last;
rewrite /(.*)/(.*) /?subtopic=$1&name=$2 last;
将规则更改为此
rewrite^(.*)$/?子主题=字符和名称=上次$1代码>这是一个步骤,它可以识别链接中的某些内容,但当我尝试查看字符页时,它会说字符/永恒不存在。它是否仍在位置/{}
下?@Rafau它应该在位置
之外。尝试过了,只有当我进入urlhttp://www.example.com/ban
那是以前的:http://example.com/?subtopic=ban
如果我尝试另一个类似于字符的url-出于某种原因它不起作用(可能是我的网站,将尝试一些事情)@Rafau尝试添加第三条规则:rewrite/(.*)/?subtopic=$1 last代码>