本文主要是介绍SEO部分需求,301重定向设置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
nginx 配置重定向 【
参考 http://www.cnblogs.com/benio/archive/2010/08/16/1800584.html
】
进行了301重定向,把www .jefflei.com和jefflei.com合并,并把之前的域名也一并合并.
server {
server_name www.jefflei.com jefflei.com ;
if ($host != 'www.jefflei.com' ) {
rewrite ^/(.*)$ http://www.jefflei.com/$1 permanent;
}
...
}
检测重定向 设置结果,如果输入域名,返回200,表示重定向设置失败,如果是返回301 表示成功
http://tool.chinaz.com/pagestatus/default.aspx?qq-pf-to=pcqq.c2c
================================================================================
nginx 配置文件:
vhosts.conf 文件内容:
server {
listen 80 default;
server_name _ A.com www.A.com;
if ($host != 'www.A.com' ) {
rewrite ^/(.*)$ http://www.A.com/$1 permanent;
}
index index.html index.htm index.jsp;
root /BBB/www/default;
#location ~ \.jsp$ {
# proxy_pass http://127.0.0.1:8080;
#}
#location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
#{
# expires 30d;
#}
#location ~ .*\.(js|css)?$
#{
# expires 1h;
#}
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host:$server_port;
}
location ^~ /image/ {
root /data;
}
location ~* \.(js|css|jpg|jpeg|gif|png|swf)$ {
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host:$server_port;
expires 30d;
}
access_log /BBB/log/nginx/access/default.log;
}
manager.conf 文件内容 :
server{
listen 80 ;
server_name manager.A.com;
index index.html index.htm index.jsp;
root /home/education/manager/apache-tomcat-7.0.61/webapps/education;
location / {
proxy_pass http://127.0.0.1:8090;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host:$server_port;
}
access_log /BBB/log/nginx/access/manager_default.log;
}
这篇关于SEO部分需求,301重定向设置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!