Nginx: [emerg] directive "rewrite" is not terminated by ";"

Scroll Down

Nginx: [emerg] directive "rewrite" is not terminated by ";"

报错的意思是说rewrite应该以分号“;”结尾,但是没检测到分号。

这种情况大多是因为规则中存在{},从而nginx将 } 识别为规则结尾,造成报错, 此时可以使用双引号""把规则包起来可以避免这个错误

例如:

rewrite "^\/rny\/webface\/mailApps\/(.*)(\/\d{6,})(.*)$" /web/app/dev/$1