全球主机交流论坛

标题: nginx 重定向错误 [打印本页]

作者: polar    时间: 2013-1-15 22:37
标题: 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

作者: 大胡子    时间: 2013-1-15 22:39
(, 下载次数: 0)
作者: jianggau    时间: 2013-1-15 22:40
提示: 作者被禁止或删除 内容自动屏蔽
作者: pojtt    时间: 2013-1-15 22:40

  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.         }
复制代码

作者: 大胡子    时间: 2013-1-15 22:41
你绑定也重复了

两个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;
复制代码

作者: muyang    时间: 2013-1-15 22:43
本帖最后由 muyang 于 2013-1-15 22:45 编辑

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




欢迎光临 全球主机交流论坛 (https://hostloc.onozo.cc/) Powered by Discuz! X3.4