阿里云Nginx服务器配置301重定向
来源:互联网 发布:天宇水利预算软件 编辑:程序博客网 时间:2024/05/22 03:13
网上查了一下linux 301重定向的代码,都是说要在 .htaccess 文件中添加重定向代码,但是我试了好多次,都没有成功。这是怎么回事?莫非这些代码都有错误?
于是,我又继续查找资料,最终在阿里云论坛里找到了答案,不看不知道,一看吓一跳哇,方法非常简单,不是在.htaccess 文件里修改,而是要在 .conf 文件里修改,就是你绑定域名的那个文件里修改,如果你用的阿里云自带的系统,那么这个.conf文件在 /alidata/server/nginx-1.2.5/conf/vhosts 这个目录里。打开这个文件phpwind.conf编辑:
server { listen 80; server_name www.xiaochunchun.com xiaochunchun.com; if ($host != 'www.xiaochunchun.com' ) { rewrite ^/(.*)$ http://www.xiaochunchun.com/$1 permanent; } index index.html index.htm index.php; root /alidata/www/ycsc/web; location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } include /alidata/server/nginx/conf/rewrite/phpwind.conf; access_log /alidata/log/nginx/access/ycsc.log; }
检验是否配置正确,连接远程控制
cd /alidata/server/nginx/sbin/
输入命令:
./nginx -t
出现如下两行,即表示配置正确。
the configuration file /usr/local/nginx/conf/nginx.conf syntax is okconfiguration file /usr/local/nginx/conf/nginx.conf test is successful
重启nginx~ 输入指令(仍在在sbin目录下)~
./nginx -s reload
测试成功,利用站长之家检测:
http://tool.chinaz.com/pagestatus
阅读全文
0 0
- 阿里云Nginx服务器配置301重定向
- nginx服务器 301重定向主页 rewrite配置
- Nginx 301重定向的配置
- 服务器 nginx配置ssl并http重定向到https
- 阿里云tomcat实现301重定向
- nginx 301重定向
- nginx 301重定向
- nginx配置域名重定向
- Nginx重定向[Rewrite]配置
- nginx配置(三)重定向
- nginx配置404重定向
- 阿里云LINUX服务器配置HTTPS(NGINX)
- IT-op-nginx--nginx重定向配置
- IIS服务器配置重定向
- nginx伪静态配置301重定向,域名301重定向
- nginx站点配置之域名301重定向
- nginx下虚拟目录配置301域名重定向
- Nginx 301重定向域名
- 回溯法——0-1背包问题
- 启动myeclipse的时候弹出来workspace in use or cannot be created, choose a different one
- hadoop2.6.0学习
- Hdu4135 Co-prime
- SSL 1333_地鼠的困境_匹配
- 阿里云Nginx服务器配置301重定向
- saas平台产品使用合同(模板)
- PCL中读取pcd点云数据的两种方法
- SPARK图计算缓存踩坑记录整理
- linux系统编程之信号(六):信号发送函数sigqueue和信号安装函数sigaction
- 浅谈:Java静态变量
- MySQL安装操作
- 面试题 8: 旋转数组的最小数字
- linux系统编程之信号(七):被信号中断的系统调用和库函数处理方式