nginx configuration redirection [
Reference http://www.cnblogs.com/benio/archive/2010/08/16/1800584.html
】
Performed a 301 redirect, merged www.jefflei.com and jefflei.com, and merged the previous domain name.
server {
server_name www.jefflei.com jefflei.com ;
if ($host != 'www.jefflei.com' ) {
rewrite ^/(.*)$ http://www.jefflei.com/$1 permanent;
}
...
}
Detect the redirection setting result, if the domain name is entered, it will return 200, indicating that the redirection setting failed, if it is, it will return 301, indicating success
http://tool.chinaz.com/pagestatus/default.aspx?qq-pf-to=pcqq.c2c
================================================================================
nginx configuration file:
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 file content:
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;
}