https is redirecting to http , how can I do the reverse ?

August 31, 2016 1.7k views
Apache

Hi, I have installed https with letsencrypt, but the https url is redirecting to http

how can I fix it ?

I have both .conf files, and .htaccess

ssl.conf:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName xxxxx.com
    ServerAlias www.xxxx.com
    DocumentRoot /var/www/xxxx.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/var/www/xxxx.com/public_html">
        AllowOverride All
        Options Indexes FollowSymLinks MultiViews
    </Directory>

SSLCertificateFile /etc/letsencrypt/live/xxxx.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxx.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/xxxx.com/chain.pem
</VirtualHost>
</IfModule>

nossl.conf:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName xxxx.com
    ServerAlias www.xxxx.com
    DocumentRoot /var/www/xxxx.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/var/www/xxxx.com/public_html">
        AllowOverride All
        Options Indexes FollowSymLinks MultiViews
    </Directory>

</VirtualHost>

.htaccess of my site:

<IfModule mod_rewrite.c>
    #Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>

2 Answers

Hi!

I don't see any rules that might cause an https->http redirect. What web app are you running on that domain name? Is it possible that it might be causing the redirect? Does it also happen in a different browser or in private/incognito mode?

Or, if you do not mind, please post the domain name so that I can see if it's the same on my end.

Try the following config. Restart your server without fail .It works on Centos 7

nossl.conf

<VirtualHost *:80>

    ServerName yoursite.com
    ServerAlias www.yoursite.com
    DocumentRoot /var/www/yoursite.com/public_html
    <Directory "/var/www/ranmarc.com/public_html">
        Options FollowSymLinks MultiViews
        # AllowOverride controls what directives may be placed in .htaccess files.      
        AllowOverride All
        # Controls who can get stuff from this server file
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /var/www/yoursite.com/error.log
    CustomLog /var/www/yoursite.com/requests.log combined
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =yoursite.com [OR]
    RewriteCond %{SERVER_NAME} =www.yoursite.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>

    ServerName yoursite.com
    ServerAlias www.yoursite.com
    DocumentRoot /var/www/yoursite.com/public_html
    <Directory "/var/www/yoursite.com/public_html">
        Options FollowSymLinks MultiViews
        # AllowOverride controls what directives may be placed in .htaccess files.      
        AllowOverride All
        # Controls who can get stuff from this server file
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /var/www/yoursite.com/error.log
    CustomLog /var/www/yoursite.com/requests.log combined
    SSLCertificateFile /etc/letsencrypt/live/yoursite.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/yoursite.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateChainFile /etc/letsencrypt/live/yoursite.com/chain.pem
</VirtualHost>
</IfModule>
Have another answer? Share your knowledge.