0

I know this question has been posted ad-nauseam; however, I still cannot manage to get a working solution.

OS being used is Debian 7 Wheezy.

vHosts file (/etc/apache2/sites-available/default):

<VirtualHost *:80>
  ServerName www.example.com
  ServerAlias *.example.com
  RedirectPermanent / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>
        ServerAdmin domains@example.com
        SSLEngine on
        ServerName www.example.com
        SSLCertificateFile /etc/apache2/ssl/ev-cert.crt
        SSLCertificateKeyFile /etc/apache2/ssl/private.key
        SSLCertificateChainFile /etc/apache2/ssl/intermediate.crt
        SSLProtocol all
        SSLCipherSuite HIGH:MEDIUM
        DocumentRoot /var/www

    <Directory /var/www/>
            Options -Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

        ErrorLog /var/log/apache2/error.log
        LogLevel info
        CustomLog /var/log/apache2/access.log combined
</VirtualHost>

EDIT (Added description of the problem):

Upon restarting apache2, I get no errors; however, when I visit http://www.example.com it goes no where and get a server connection error (cannot connect to server), though when I visit https://www.example.com I get through just fine. There are no logs in apache to indicate a failure.

Jenny D
  • 28,400
  • 21
  • 80
  • 117
Kris
  • 1

1 Answers1

-1

You do it wrong. All you need mod_rewrite. So Basicly first check that this module is on in httpd.conf

# vi /usr/local/etc/apache24/httpd.conf
LoadModule rewrite_module libexec/apache24/mod_rewrite.so

create .htaccess in folder you want redirect to https

# touche /usr/local/www/site1/.htaccess

then add rule for redirection

# echo 'RewriteEngine On' >> /usr/local/www/site1/.htaccess
# echo 'RewriteCond %{HTTPS} off' >> /usr/local/www/site1/.htaccess
# echo 'RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}' >> /usr/local/www/site1/.htaccess

Or you can add this line to youre vhost.conf file for http delete RedirectPermanent line and add

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

save and restart apache # apachectl restart P.S. All path for freebsd don't know what os you use.

Kzerza
  • 134