MJJ论坛

 找回密码
 注册
查看: 5095|回复: 8

[Windows VPS] nginx 重定向错误

[复制链接]
发表于 2013-1-15 22:37:07 | 显示全部楼层 |阅读模式

  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:09 | 显示全部楼层
100.png (12.84 KB, 下载次数: 0)

点评

替换?  发表于 2013-1-15 22:40
发表于 2013-1-15 22:40:48 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 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.         }
复制代码

评分

参与人数 1威望 +5 收起 理由
polar + 5 很给力!

查看全部评分

发表于 2013-1-15 22:41:42 | 显示全部楼层
你绑定也重复了

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

评分

参与人数 1威望 +5 收起 理由
polar + 5 很给力!

查看全部评分

发表于 2013-1-15 22:43:04 | 显示全部楼层
本帖最后由 muyang 于 2013-1-15 22:45 编辑

顶楼上的
发表于 2013-1-15 22:43:52 | 显示全部楼层
大胡子V5
发表于 2013-1-15 22:45:49 | 显示全部楼层
@楼主 :server插server,厉害啊
@4,5,6 :rewrite死循环了

评分

参与人数 1威望 +10 收起 理由
大胡子 + 10 赞一个!

查看全部评分

发表于 2013-1-15 22:59:19 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|MJJ论坛

Copyright MJJ论坛 © 2022 All Rights Reserved.

快速回复 返回顶部 返回列表