VPS侦探论坛

 找回密码
 注册
查看: 5790|回复: 6

军哥帮我审核一下这段301代码及conf文件有没有错误

[复制链接]
发表于 2013-10-5 17:49:52 | 显示全部楼层 |阅读模式

www.xxx.com.conf文件
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.xxx.com xxx.com;
  5.                  server_name xxx.com;
  6.                  if ($host != 'www.xxx.com' ) {
  7.                      rewrite  ^/(.*)[        DISCUZ_CODE_0        ]nbsp; http://www.xxx.com/$1  permanent;
  8.                  }
  9.                 index index.html index.htm index.php default.html default.htm default.php;
  10.                 root  /home/wwwroot/www.xxx.com;

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

[ 本帖最后由 408904199 于 2013-10-5 18:02 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-10-6 09:10:22 | 显示全部楼层


把你添加的代码和server_name里的xxx.com删掉,按http://lnmp.org/faq/lnmp-nginx-301-rewrite.html 添加
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-10-13 02:51:25 | 显示全部楼层

回复 2# 的帖子


谢谢军哥耐心解答,这个问题解决啦

但是又有一个新问题出现,我最近有设置了404页面,404页面的301不能跳转到带www的域名上面。
比如http://xxx.com/404,他不会跳转到http://www.xxx.com/404上面去。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-10-13 08:20:43 | 显示全部楼层



贴配置
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-10-13 13:42:10 | 显示全部楼层

www.xxx.com.conf配置文件


  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.xxx.com;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/www.xxx.com;
  7.                 error_page 404 /404.html;

  8.                 include discuzx.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.         }
  26. server {
  27. server_name xxx.com;
  28. return 301 $scheme://www.xxx.com$request_uri;
  29. }
复制代码

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2013-10-13 13:42:57 | 显示全部楼层

nginx.conf配置文件


  1. user  www www;worker_processes 1;error_log  /home/wwwlogs/nginx_error.log  crit;pid        /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.
  2. worker_rlimit_nofile 51200;events
  3. {
  4.   use epoll;
  5.   worker_connections 51200;
  6. }http
  7. {
  8.   include       mime.types;
  9.   default_type  application/octet-stream;  server_names_hash_bucket_size 128;
  10.   client_header_buffer_size 32k;
  11.   large_client_header_buffers 4 32k;
  12.   client_max_body_size 50m;  sendfile on;
  13.   tcp_nopush     on;  keepalive_timeout 60;  tcp_nodelay on;  fastcgi_connect_timeout 300;
  14.   fastcgi_send_timeout 300;
  15.   fastcgi_read_timeout 300;
  16.   fastcgi_buffer_size 64k;
  17.   fastcgi_buffers 4 64k;
  18.   fastcgi_busy_buffers_size 128k;
  19.   fastcgi_temp_file_write_size 256k;
  20.   fastcgi_intercept_errors on;  gzip on;
  21.   gzip_min_length  1k;
  22.   gzip_buffers     4 16k;
  23.   gzip_http_version 1.0;
  24.   gzip_comp_level 2;
  25.   gzip_types       text/plain application/x-javascript text/css application/xml;
  26.   gzip_vary on;
  27.   gzip_proxied        expired no-cache no-store private auth;
  28.   gzip_disable        "MSIE [1-6]\.";  #limit_zone  crawler  $binary_remote_addr  10m;  server_tokens off;
  29.   #log format
  30.   log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  31.              '$status $body_bytes_sent "$http_referer" '
  32.              '"$http_user_agent" $http_x_forwarded_for';server
  33. {
  34.   listen       80;
  35.   server_name www.lnmp.org;
  36.   index index.html index.htm index.php;
  37.   root  /home/wwwroot/default;  location ~ .*\.(php|php5)?$
  38.    {
  39.     try_files $uri =404;
  40.     fastcgi_pass  unix:/tmp/php-cgi.sock;
  41.     fastcgi_index index.php;
  42.     include fcgi.conf;
  43.    }  location /status {
  44.    stub_status on;
  45.    access_log   off;
  46.   }  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  47.    {
  48.     expires      30d;
  49.    }  location ~ .*\.(js|css)?$
  50.    {
  51.     expires      12h;
  52.    }  access_log  /home/wwwlogs/access.log  access;
  53. }
  54. include vhost/*.conf;
  55. }
复制代码
 楼主| 发表于 2013-10-13 13:48:27 | 显示全部楼层

回复 4# 的帖子


晕,问题解决 是浏览器缓存问题。谢谢军哥
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-25 03:28 , Processed in 0.027052 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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