容器技术交流

 找回密码
 立即注册
查看: 3031|回复: 2

nginx 301重定向。。。怎么设也不行呢。

[复制链接]
发表于 2011-1-22 15:53:47 | 显示全部楼层 |阅读模式
nginx 301重定向。。。怎么设也不行呢。


#------------------------- Mark: vpn User: a3333 ----------------------------
server {
listen 80;
server_name abc.com www.abc.com ;
root /home/a333_vpn/wwwroot;



location / {
index index.html index.htm index.php;
}

access_log /var/log/nginx_log_vpn combined;

error_page 404 /;

location ~ \.php$ {
include enable_php.conf;
}

if (-d $request_filename) {
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
}




上面是我原来的

我要设成 访问 abc.com 直接转到www.abc.com

在网上找资料不管是加入下面这几句

server
{
server_name abc.com;
rewrite ^(.*) http://www.abc.com$1 permanent;
}


还是直接加入:rewrite ^(.*) http://www.abc.com$1 permanent;
都不行。。。


下面这种方法我也没成功。不过我还有别的二级域名。所以下面这个我不试用。
if ($host != ‘abc.com’ ) {
rewrite ^/(.*)$ http://www.abc.com/$1 permanent;
}


哪位大哥哥帮我一下。看哪里出问题了。
 楼主| 发表于 2011-1-23 09:26:28 | 显示全部楼层
有会这个的没。
 楼主| 发表于 2011-1-24 08:58:07 | 显示全部楼层
help me help me
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|URLOS ( 粤ICP备18087780号 )

GMT+8, 2025-5-12 11:24 , Processed in 0.029359 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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