http和https相关的问题?

怎么使自己的网站在输入http时,不允许访问,使其转化为https即可访问?
阅读 4.3k
7 个回答

重定向即可!比如nginx,启用http2,其中版本要在1.90以上,然后先配置443端口,最后把http 80端口请求转发到443

直接写伪静态 做 301 重定向
将http请求转到https即可

这个需要在服务器端进行重定向配置,不同的服务器程序有不同的设置方法,你要参考对应的。

新手上路,请多包涵

301重定向
在Apache 中,有个很重要的文件.htaccess,通过对它的设置,可以实现很多强大的功能,301 重定向只是其中之一。

可以把 morethink.cn和www.morethink.cn合并到一个server上去,使用301永久重定向。
然后将 https://morethink.cn 转到 https://www.morethink.cn 去。不过要在https://www.morethink.cn
配置default_server ssl;
301永久重定向可以把搜索引擎的权重全部集中到 https://www.morethink.cn 上。

配置如下:

    server {
        listen       80;
        server_name morethink.cn,www.morethink.cn;
        return 301 https://www.morethink.cn$request_uri;
    }
    server {
        listen 443;
        server_name morethink.cn;
        return 301 https://www.morethink.cn$request_uri;
    }
    server {
        listen 443 default_server ssl;
        server_name  www.morethink.cn;
    # ssl配置
    }

Apache的配置文件参考在官方文档就有: https://wiki.apache.org/httpd...

配置原理都跟Nginx的一样,你既可以使用虚拟主机Redirect跳转,也可以公用一个VirtualHost使用Rewrite跳转

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题