VPS侦探论坛

 找回密码
 注册
查看: 6976|回复: 2

nginx 301重定向的配置 100%无错,已测试

[复制链接]
发表于 2012-4-16 11:48:34 | 显示全部楼层 |阅读模式

配置文件路径/usr/local/nginx/conf/vhost/zmanhua.com.conf

vi zmanhua.com.conf

代码如下:
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.zmanhua.com;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/zmanhua.com;

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

  14.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  15.                         {
  16.                                 expires      30d;
  17.                         }

  18.                 location ~ .*\.(js|css)?$
  19.                         {
  20.                                 expires      12h;
  21.                         }

  22.                 access_log off;
  23.         }
  24. server {
  25. server_name zmanhua.com;
  26. rewrite ^(.*) http://www.zmanhua.com$1 permanent;
  27. }
复制代码
之后重启/root/lnmp restart 就好了~

评分

参与人数 1威望 +6 收起 理由
licess + 6

查看全部评分

美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-4-16 15:11:56 | 显示全部楼层


注意一点:前面的server name只能包含带www的哦,不带www的写下面
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-7-4 11:01:22 | 显示全部楼层

我按照这个方法做的,百度还是收录的不一样,排名也不一样,快照也不一样
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-23 09:29 , Processed in 0.026356 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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