网站首页 > 基础教程 正文
网站添加了https证书后,当http方式访问网站时就会报404错误,所以需要做http到https的强制跳转设置.
---------------一、采用nginx的rewrite方法---------------------
下面是将所有的http请求通过rewrite重写到https上。
例如将所有的www.nihao.com域名的http访问强制跳转到https。
下面配置均可以实现:
server {
listen 80;
server_name www.nihao.com;
index index.html index.php index.htm;
access_log /usr/local/nginx/logs/8080-access.log main;
error_log /usr/local/nginx/logs/8080-error.log;
#重点在此
if ($host ~* "^nihao.com#34;) {
rewrite ^/(.*)$ https://www.nihao.com/ permanent;
}
location ~ / {
root html;
index index.html index.php index.htm;
}
}
- 上一篇: GitHub 用户注意:Sawfish 钓鱼攻击来了
- 下一篇: nginx 关键字反向代理
猜你喜欢
- 2024-11-27 php安全编程?python暴力破解,论python的牛逼性
- 2024-11-27 CVE-2024-4577 PHP CGI 远程代码执行漏洞分析
- 2024-11-27 使用VS Code调试PhpStudy环境里的代码
- 2024-11-27 Web安全之URL跳转漏洞
- 2024-11-27 01.linux上安装宝塔部署PHP项目
- 2024-11-27 教程 | 从零开始开发一个PHP留言板(三)——页面制作
- 2024-11-27 WordPress网站被利用xmlrpc.php攻击解决办法
- 2024-11-27 Nginx 反向代理学习及实例笔记
- 2024-11-27 phpMyAdmin使用教程(图文详解)
- 2024-11-27 CentOS8 安装数据库管理工具之phpMyAdmin5.1.1
- 最近发表
- 标签列表
-
- jsp (69)
- gitpush (78)
- gitreset (66)
- python字典 (67)
- dockercp (63)
- gitclone命令 (63)
- dockersave (62)
- linux命令大全 (65)
- pythonif (86)
- location.href (69)
- dockerexec (65)
- tail-f (79)
- queryselectorall (63)
- location.search (79)
- bootstrap教程 (74)
- deletesql (62)
- linuxgzip (68)
- 字符串连接 (73)
- html标签 (69)
- c++初始化列表 (64)
- mysqlinnodbmyisam区别 (63)
- arraylistadd (66)
- mysqldatesub函数 (63)
- window10java环境变量设置 (66)
- c++虚函数和纯虚函数的区别 (66)