Lar*_*ars 6 nginx 301-redirect
因此,curl -i http://example.com
在我的服务器上执行操作时,我在正文中收到以下响应:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
它显示我正在运行 nginx,我想删除此信息。
这是我的 nginx.conf 重定向到 HTTPS(以及我尝试更改 301 响应正文):
server {
listen 80;
server_name localhost;
error_page 301 = /301.html;
location /301.html {
return 301 "<h1>use https</h1>";
}
return 301 https://$host$request_uri;
}
Run Code Online (Sandbox Code Playgroud)
知道如何更改 301 响应正文吗?
小智 4
以下 URL 上有一篇关于自定义错误页面的精彩文章。以下是如何使用它从 HTTP 响应中删除 nginx 品牌的简短301
版本302
。
http {
map $status $status_text {
301 'Moved Permanently';
302 'Found';
}
server {
listen 1.1.1.1;
server_name _;
error_page 301 302 /error.html;
location = /error.html {
ssi on;
internal;
auth_basic off;
root /var/website/custom_error_pages;
}
root /var/website/empty_dir;
location / {
return 301 https://www.website.com$request_uri;
}
}
Run Code Online (Sandbox Code Playgroud)
<html>
<head><title>www.website.com</title></head>
<body><h1>
<!--# echo var="status" default="000" --> - <!--# echo var="status_text" default="Error" -->
</h1></body>
</html>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9962 次 |
最近记录: |