nginx设置域名重定向301跳转规则
作者:高景洋 日期:2020-10-17 22:00:57 浏览次数:1629
以下绿色部分即为nginx.conf 301 配置规则
server {
listen 80;server_name www.xp5.cn;
------------------------------
# 重定向301跳转
if ($host != 'www.xp5.cn' ){rewrite ^/(.*)$ http://www.xp5.cn/$1 permanent;
}
-------------------------------
#access_log logs/host.access.log main;
location / {
********
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
本文永久性链接:
<a href="http://r4.com.cn/art145.aspx">nginx设置域名重定向301跳转规则</a>
<a href="http://r4.com.cn/art145.aspx">nginx设置域名重定向301跳转规则</a>
当前header:Host: r4.com.cn
X-Host1: r4.com.cn
X-Host2: r4.com.cn
X-Host3: 127.0.0.1:8080
X-Forwarded-For: 3.15.0.46
X-Real-Ip: 3.15.0.46
X-Domain: r4.com.cn
X-Request: GET /art145.aspx HTTP/1.1
X-Request-Uri: /art145.aspx
Connection: close
Accept: */*
User-Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Accept-Encoding: gzip, br, zstd, deflate