VPS侦探论坛

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

军哥请进;Discuz x3 Nginx 301 问题。

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

Discuz x3 nginx 301问题

设置了301  不带WWW跳转到带WWW  ;

例子:输入xxx.com跳转到www.xxx.com 这个功能实现了,但是只有首页可以跳转。




输入xxx.com/forum-10-1.html 就不会跳转到 www.xxx.com/forum-10-1.html

请问怎么实现输入 xxx.com/forum-10-1.html 也会跳转到 www.xxx.com/forum-10-1.html

现目前我使用的301规则:
  1. server_name www.xxx.com yoursite.com;
  2.     if ($host != 'www.xxx.com' ) {
  3.         rewrite  ^/(.*)$  http://www.xxx.com/$1  permanent;
  4. }
复制代码

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


这个301代码完全是可以的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-5-30 11:22:17 | 显示全部楼层

回复 2# 的帖子


但是输入xxx.com/forum-10-1.html 就不会跳转到 www.xxx.com/forum-10-1.html
求解决方法
按照正常来说,这个代码可以实现输入xxx.com/forum-10-1.html 跳转到 www.xxx.com/forum-10-1.html  ?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-5-30 11:32:03 | 显示全部楼层

回复 3# 的帖子




贴全部配置***。com和www.***.com的全部配置
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-5-30 20:12:11 | 显示全部楼层

回复 4# 的帖子


nginx.conf文件
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 50m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39.                 #log format
  40.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  41.              '$status $body_bytes_sent "$http_referer" '
  42.              '"$http_user_agent" $http_x_forwarded_for';

  43. server
  44.         {
  45.                 listen       80;
  46.                 server_name www.xxx.com;
  47.                 index index.html index.htm index.php;
  48.                 root  /home/wwwroot;
  49.                 include discuzx.conf;

  50.                 location ~ .*\.(php|php5)?$
  51.                         {
  52.                                 try_files $uri =404;
  53.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  54.                                 fastcgi_index index.php;
  55.                                 include fcgi.conf;
  56.                         }

  57.                 location /status {
  58.                         stub_status on;
  59.                         access_log   off;
  60.                 }

  61. server_name www.xxx.com xxx.com;
  62.     if ($host != 'www.xxx.com' ) {
  63.         rewrite  ^/(.*)$  http://www.xxx.com/$1  permanent;
  64. }
  65.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  66.                         {
  67.                                 expires      30d;
  68.                         }

  69.                 location ~ .*\.(js|css)?$
  70.                         {
  71.                                 expires      12h;
  72.                         }

  73.                 access_log  /home/wwwlogs/access.log  access;
  74.         }
  75. include vhost/*.conf;
  76. }
复制代码

[ 本帖最后由 408904199 于 2013-5-30 20:15 编辑 ]

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

发表于 2013-5-30 20:58:19 | 显示全部楼层

配置文件都改错了后部分代码为
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.xxx.com;
  5.                 index index.html index.htm index.php;
  6.                 root  /home/wwwroot;
  7.                 include discuzx.conf;

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

  15.                 location /status {
  16.                         stub_status on;
  17.                         access_log   off;
  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/access.log  access;
  28.         }
  29. server
  30.         {
  31.                 listen       80;
  32.                 server_name xxx.com;
  33.                 if ($host != 'www.xxx.com' ) {
  34.                     rewrite  ^/(.*)$  http://www.xxx.com/$1  permanent;
  35.                 }
  36.         }               
  37. include vhost/*.conf;
  38. }
复制代码
 楼主| 发表于 2013-5-30 21:19:33 | 显示全部楼层

回复 6# 的帖子


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

本版积分规则

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

GMT+8, 2024-9-24 15:28 , Processed in 0.034062 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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