JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

http请求域名强制跳转https 短域名伪装的特征地址栏地址会不会进行二次跳转吗

wys521 2024-09-27 14:26:23 精选教程 212 ℃ 0 评论
网站添加了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;
    }
}

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表