[Windows VPS] nginx 重定向错误 只看楼主


  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.loc16.com loc16.com;
  5. server {
  6. server_name www.loc16.com loc16.com;
  7. rewrite ^/(.*) http://www.loc16.com/$1 permanent;
  8. }
  9.                 index index.html index.htm index.php default.html default.htm default.php;
  10.                 root  /data/loc16.com;

  11.                 include none.conf;
  12.                 location ~ .*\.(php|php5)?$
  13.                         {
  14.                                 try_files $uri =404;
  15.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  16.                                 fastcgi_index index.php;
  17.                                 include fcgi.conf;
  18.                         }

  19.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  20.                         {
  21.                                 expires      30d;
  22.                         }

  23.                 location ~ .*\.(js|css)?$
  24.                         {
  25.                                 expires      12h;
  26.                         }

  27.                 access_log off;
  28.         }
  29. ~
想把loc16.com www.loc16.com 重定向成 http://www.loc16.com

用上面的命令是成功了。但是重启lnmp的时候有错误。 怎么样才不出错误。

Reload LNMP...
Reload Nginx configure...
nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/vhost/www.loc16.com.conf:6
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/vhost/www.loc16.com.conf:6
Nginx program is reloding!

SUCCESS! Reloading service MySQL
Reload service php-fpm  done
100.png (12.84 KB)
(下载次数: 0, 2013-1-15 22:39 上传)
提示: 作者被禁止或删除 内容自动屏蔽
  • 4# pojtt
  • 2013-1-15 22:40:56

  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.loc16.com loc16.com;

  5. rewrite ^/(.*) http://www.loc16.com/$1 permanent;

  6.                 index index.html index.htm index.php default.html default.htm default.php;
  7.                 root  /data/loc16.com;

  8.                 include none.conf;
  9.                 location ~ .*\.(php|php5)?$
  10.                         {
  11.                                 try_files $uri =404;
  12.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  13.                                 fastcgi_index index.php;
  14.                                 include fcgi.conf;
  15.                         }

  16.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  17.                         {
  18.                                 expires      30d;
  19.                         }

  20.                 location ~ .*\.(js|css)?$
  21.                         {
  22.                                 expires      12h;
  23.                         }

  24.                 access_log off;
  25.         }
你绑定也重复了

两个server_name www.loc16.com loc16.com;
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name loc16.com;}
  5. server {
  6. server_name www.loc16.com;
  7. rewrite ^/(.*) http://www.loc16.com/$1 permanent;
  • 6# muyang
  • 2013-1-15 22:43:04
本帖最后由 muyang 于 2013-1-15 22:45 编辑

顶楼上的
大胡子V5
@楼主 :server插server,厉害啊
@4,5,6 :rewrite死循环了
  • 9# lxqfff
  • 2013-1-15 22:59:19
提示: 作者被禁止或删除 内容自动屏蔽