nginx设置域名重定向301跳转规则
作者:高景洋 日期:2020-10-17 22:00:57 浏览次数:1598
以下绿色部分即为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: 18.97.9.175
X-Real-Ip: 18.97.9.175
X-Domain: r4.com.cn
X-Request: GET /art145.aspx HTTP/1.1
X-Request-Uri: /art145.aspx
Connection: close
User-Agent: CCBot/2.0 (https://commoncrawl.org/faq/)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
If-Modified-Since: Thu, 08 Aug 2024 11:34:47 GMT
Accept-Encoding: br,gzip