VestaCP使用.htaccess实现强制SSL

  • 6
  • 8,543 views
  • A+
所属分类:Linux

VestaCP面板使用.htaccess轻松实现强制SSL,网站访问跳转到https链接。方法由西秦公子提供。

在网站根目录下.htaccess文件里加入以下几行:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

另一种方法就是使用nginx模版:

cd /usr/local/vesta/data/templates/web
wget http://c.vestacp.com/0.9.8/rhel/force-https/nginx.tar.gz
tar -xzvf nginx.tar.gz
rm -f nginx.tar.gz

然后修改你的虚拟主机的模板为Forece-SSL即可

如果你安装的是新版自定义结构的没装apache,那么.htaccess方法不适用了。新版看这里

weinxin
我的微信公众号
我的微信公众号扫一扫

发表评论

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

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

    • sven sven 4

      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

      你这是准备上SSL了么

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

          @sven 我的ss站已经用了,博客估计以后也会上,我有点期待https://letsencrypt.org/

            • sven sven 4

              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

              @厘米 免费的SSL啊,wosign不是已经免费2年了么。你的SS站点网址是多少?

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

                  @sven 我ss网站是https://shadows.pw/,有需要的话我可以发码给你!

            • sven sven 4

              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

              http://www.seavia.com/jianzhan/seo/ssl-https-baidu-seo-solution.html 可以看看我的这个强制跳转,目测比他总结的全面点。

              • 超越自我吧 超越自我吧 0

                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

                表示受教,已经保留一份备用。