AMH面板强制ssl的rewrite规则及400错误

  • 11
  • 8,374 views
  • A+
所属分类:工具资源

很多站长喜欢AMH面板的一个重要原因是有各种功能的扩展模块,所以像添加ssl证书,网站开启https访问也是很容易的事。今天尝试开启强制ssl的时候访问http页面发现400 Bad Request错误,搜索了一番最后发现是自己绑定域名的时候少绑了一个,真是粗心。要在AMH下实现网站强制https访问的几个步骤如下:

1.后台模块扩展那里搜索ssl,安装BBShijieSSL-1.1模块。

2.在虚拟主机-ssl配置那里选择主机,然后贴上密钥、证书的内容,点击新增就可以了。此时网站已经可以用https访问了。

3.模块扩展那里安装AMRewrite模块,然后管理模块-新增Rewrite规则:名字就起个forcessl,内容如下

if ($server_port = 80) {
return 301 https://$server_name$request_uri;
}
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
error_page 497 https://$server_name$request_uri;

编辑网站虚拟主机,在Rewrite规则那里下拉菜单选中forcessl,点击保存。

最后执行amh nginx restart重启nginx,就可以生效。这时你访问http页面已经可以跳转到https页面了。

weinxin
我的微信公众号
我的微信公众号扫一扫
    • Leejon Leejon 2

      Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

      我修改了listen 443 ssl http2;
      然后新增Rewrite规则 重启
      SSL 连接出错 ERR_SSL_PROTOCOL_ERROR
      证书是wosign,这个是什么问题呢?

          • 厘米 厘米 9

            Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

            @Leejon 你开了http2啊,nginx版本够高吗?

                • Leejon Leejon 2

                  Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                  @厘米 我用AMH v44面板右下角的版本是Nginx 1.4.4 这个版本够高吗? :?:

                • Leejon Leejon 2

                  Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                  用得是v44版/usr/local/nginx/sbin/nginx -v 查看是1.9.6 谢谢解答。直接点回复你,但页面不显示内容。

                    • janethan janethan 1

                      Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                      完美解决!
                      多谢!!!