nginx - 为什么网站不使用 nginx 重定向
问题描述
我正在尝试将域 example.com 重定向到另一个网站 example.blogspot.com (它不在我的服务器中)。
我一直在使用htaccess
and cpanel
,所以很容易重定向。但是为什么重定向在 nginx 中不起作用。
nginx/1.15.10
在版本和最新版本中使用以下方式没有看到任何效果vesta control panel
,
仍然显示由vesta控制面板生成的默认页面(index.html)。我应该更改 public_html 吗?还是重启服务器?
我已经nginx.conf
使用以下代码进行了编辑。
方法一
http{
server{
listen 80;
server_name example.com www.example.com;
return 301 https://example.blogspot.com$request_uri;
}
.....
}
方法二
http{
server{
listen [::]:80;
listen 80;
server_name example.com www.example.com;
return 301 https://example.blogspot.com$request_uri;
}
.....
}
方法三
http{
server {
server_name .example.com;
return 301 $scheme://example.blogspot.com;
}
....
}
保存后重启ngix
sudo service nginx restart
sudo systemctl restart nginx
解决方案
最后,添加Server Ip address
监听端口重定向域
http{
server{
listen my.server.ip.address:80;
server_name example.com www.example.com;
return 301 https://example.blogspot.com$request_uri;
}
.....
}
推荐阅读
- plc - 是否可以在结构化文本中间接索引数组(IEC 61131-3 标准)
- java - Android 上的简单 MVVM 架构和 Java 上的 AndroidX
- postgresql - 无法从 pg_basebackup 恢复 postgres v11
- webforms - 如何在 Decibel Insight 中实施表单分析跟踪?
- javascript - 如何将 2 个文档(PDF 和 XFDF)从 C# .NET Core WebAPI 控制器返回到 SPA?
- excel - VBA函数用最后一个非空值填充空单元格
- ios - AKButton和手势点击冲突
- java - 无法解析超类型的类。请确保您具有所需的依赖项
- angular - 如何通过更新其 FormControl 将单选按钮设置为选中状态
- python - 获取一列是最大值,另一列是最小值的列的值