确认问题
实现nginx防盗链,报错
[root@lnmp1 conf]# nginx -t
nginx: [emerg] invalid number of arguments in "rewrite" directive in /usr/local/nginx/conf/nginx.conf:162
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
问题分析
[root@lnmp1 conf]# nginx -t
nginx: [emerg] invalid number of arguments in "rewrite" directive in /usr/local/nginx/conf/nginx.conf:162
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
/*大概意思就是:nginx在本地文件路径的配置文件中存在了错误,导致无法继续运行。
*具体错误定位在了conf配置文件的第162行。
*错误原因:“rewrite”指令中存在无效数量的参数。
*/
- 因为报错提示是因为rewarite存在无效参数,所以,我检查了相关的几点
- 检查宿主主机的本地解析文件,没有问题
- 检查在配置文件中是否出现中文或者空格,没有问题
- 检查配置文件是否有手残,有
问题定位
rewrite ^\ http://www.daolian.org;
我把Linux的反斜杠和正斜杠弄错了,应该使用的是 /
Linux和Unix:
“/”表示路径,“\”表示转义
Linux中\和/的区别,正斜杠和反斜杠的区别
修改正确之后,错误解决