全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1016|回复: 11
打印 上一主题 下一主题

Nginx 1.8.0 301你们对吗?

[复制链接]
跳转到指定楼层
1#
发表于 2015-5-22 10:27:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 __蛋丶碎 于 2015-5-22 11:28 编辑

server {
server_name www.sunk.eu.org sunk.eu.org;
rewrite ^(.*) http://sunk.eu.org$1 permanent;
}

就是报错 nginx: [emerg] unknown directive "server" in /usr/local/nginx/conf/hostloc.conf:1


经二楼
server {
server_name sunk.eu.org;
rewrite ^(.*) http://www.sunk.eu.org$1 permanent;
}

Stoping nginx... nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/hostloc.conf:1
failed. Use force-quit
Starting nginx... nginx (pid 15692 15691 15690 15689 15688 15687 15686 15685 15684) already running.
2#
发表于 2015-5-22 10:31:57 | 只看该作者
sunk.eu.org不能在server_name里面
3#
发表于 2015-5-22 10:33:11 | 只看该作者
试试楼上的方法
4#
发表于 2015-5-22 10:50:05 | 只看该作者
见2楼的,,

需要转的和被转你都一样了
5#
 楼主| 发表于 2015-5-22 11:19:22 | 只看该作者
Fun 发表于 2015-5-22 10:31
sunk.eu.org不能在server_name里面

server {
server_name sunk.eu.org;
rewrite ^(.*) http://www.sunk.eu.org$1 permanent;
}

Stoping nginx... nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/hostloc.conf:1
failed. Use force-quit
Starting nginx... nginx (pid 15692 15691 15690 15689 15688 15687 15686 15685 15684) already running.
7#
发表于 2015-5-22 12:06:02 | 只看该作者

不知你怎么搞的,我使用LNMP,该域名全部配置如何下,你试试:

  1. server
  2.         {
  3.                 listen 80;
  4.                 #listen [::]:80;
  5.                 server_name www.baidu.com;
  6.                 index index.html index.htm index.php default.html default.htm default.php;
  7.                 root  /home/wwwroot/www.baidu.com;

  8.                 include none.conf;
  9.                 #error_page   404   /404.html;
  10.                 location ~ [^/]\.php(/|$)
  11.                         {
  12.                                 # comment try_files $uri =404; to enable pathinfo
  13.                                 try_files $uri =404;
  14.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  15.                                 fastcgi_index index.php;
  16.                                 include fastcgi.conf;
  17.                                 #include pathinfo.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  /home/wwwlogs/www.baidu.com.log  access;
  28.         }
  29. server {
  30.             listen       80;
  31.             server_name  baidu.com;
  32.             rewrite ^/(.*) http://www.baidu.com/$1 permanent;
  33. }
复制代码
8#
发表于 2015-5-22 15:40:01 | 只看该作者
__蛋丶碎 发表于 2015-5-22 11:19
server {
server_name sunk.eu.org;
rewrite ^(.*) http://bbs.cm8.org$1 permanent;

server中需要加上:listen 80;
9#
发表于 2015-5-22 15:44:36 | 只看该作者
你 server 的上层 directive 是什么?
10#
发表于 2015-5-22 16:02:57 | 只看该作者
很明显,你需要贴全部配置。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-11 05:39 , Processed in 0.064605 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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