通过HTTPS访问网站会破坏数据库连接

时间:2016-08-01 17:58:35

标签: php .htaccess codeigniter ssl ssl-certificate

我有一个在Apache Web服务器上运行的codeigniter站点 我从letsencrypt安装了SSL

如果我通过http://example.com

访问我的网站,我的网站运行正常

但是,

如果我通过https://example.com访问该站点,但该数据库已损坏

这是我的htaccess文件

Include /etc/phpmyadmin/apache.conf
<VirtualHost *:80>
        ServerName example.org
        ServerAlias www.example.org
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        RewriteEngine on
        RewriteRule   "^/resources/(.+)" "https://example.org/_resources/$1"$
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        <Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ProxyPass /api https://localhost:8010/api
        ProxyPassReverse /api https://localhost:8010/api
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName example.org
    ServerAlias www.example.org
    DocumentRoot /var/www/html/
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/example.org-0001/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.org-0001/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/example.org-0001/chain.pem
</VirtualHost>

1 个答案:

答案 0 :(得分:1)

通过添加<VirtualHost *:443>代码

的内部来解决此问题
  <Directory /var/www/html>
        AllowOverride All 
  </Directory>