我有这个规则成功地在apache上工作但返回错误或Nginx:
rewrite ^/saison-([0-9]{1})$/pages.PHP?cat_page=saison-$1&season=$1 last;
rewrite ^/saison-([0-9]{1})/([a-z0-9-]+)$/evenements.PHP?season=$1&title=$2 last;
rewrite ^/saison-([0-9]{1})/([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)$/evenements.PHP?season=$1&title=$2&place=$3&date=$4 last;
rewrite ^/saison-([0-9]{1})/([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)/([a-z]+)$/evenements.PHP?season=$1&title=$2&place=$3&date=$4&view=$5 last;
我有 :
*重新启动Nginx:[emerg]:指令“重写”不被“;”终止在/path/rwrules.Nginx:1中
如果我从我的重写规则中删除这4行,它是有效的.
有什么问题 ?
最佳答案
阅读这个documentation.特别是:
原文链接:https://www.f2er.com/nginx/434626.htmlNote: for curly braces( { and } ),as they are used both in regexes and for block control,to avoid conflicts,regexes with curly braces are to be enclosed with double quotes (or single quotes).
所以例如:
rewrite ^/saison-([0-9]{1})$/pages.PHP?cat_page=saison-$1&season=$1 last;
应该:
rewrite "^/saison-([0-9]{1})$" /pages.PHP?cat_page=saison-$1&season=$1 last;