怎样把不带3w的域名重写向到带www的域名呢?
见到管理员给出这个代码server {
listen 80;
server_name www.gyquan.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.gyquan.com;
include none.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}
server {
listen 80;
server_name www.域名.com 域名.com;
if ($host != 'www.域名.com' ) {
rewrite ^/(.*)$ http://bbs.域名.com/$1 permanent;
}
}
这是编辑那个文件呢?
然后,如果我想把不带www的域名,301重定向到带www的域名,我应该怎样填写呢?
回复 1# 的帖子
改你的nginx.conf 或者是你的域名.conf把xxx改成你的域名就好了
server
{
listen 80;
server_name www.xxx.com xxx.com hao.xxx.com 123.xxx.com;#二级域名
if ($host != 'www.xxx.com' ) { #改成你的域名 意思就是如果访问的host不是www.xxx.com就自动跳转到www.xxx.com
rewrite ^/(.*)$ http://www.xxx.com/$1 permanent;
}
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/xxx; #网站目录不用改
include xxx.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}
[ 本帖最后由 68218866 于 2011-11-25 12:05 编辑 ] 谢谢了,我试一下看看如何
回复 2# 的帖子
我也有同样的问题这样可以解决吗?试试看看。
页:
[1]