/ 中存储网

Nginx设置rewrite需要注意的事项

2013-10-23 13:31:01 来源:itjs.cn

如果rewrite中包含{}号,则该规则要加双引号

下面这种是错误的,

rewrite ^(.*)/archives/([d]{1,5}).html$ ^(.*)/?p=$2 last;?

输入以下指令来检查配置的正确性:

/usr/local/nginx/sbin/nginx -t

nginx会提示你:

2010/10/11 11:28:22 [emerg] 28797#0: directive "rewrite" is not terminated by ";" in /usr/local/nginx/conf/nginx.conf:435 2010/10/11 11:28:22 [emerg] 28797#0: the configuration file /usr/local/nginx/conf/nginx.conf test failed

rewrite "^(.*)/archives/([d]{1,5}).html$"  ^(.*)/?p=$2 last;