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

  • 11
  • 8,182 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
我的微信公众号
我的微信公众号扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:11   其中:访客  0   博主  0

    • 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,这个是什么问题呢?

        • 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

          @Leejon 囧,我是win7 chrome

          • 厘米 厘米 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

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

                    • 厘米 厘米 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 1.9.5以上!

                • 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 谢谢解答。直接点回复你,但页面不显示内容。

                    • 厘米 厘米 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 你不强制跳转到https看http2有没有效果呢,还有用最新版的chrome试试~

                    • 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

                      完美解决!
                      多谢!!!

                        • 厘米 厘米 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

                          @janethan 不客气,解决就好!

                        • ByteCat ByteCat 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

                          666,终于成功配置了 SSL,AMH真的好用……
                          (之前拿 LNMP 配置老是出现400错误,不知道为什么……反正,AMH 成功配置了,谢谢厘米!