I've got a subsite configured like this in httpd.conf

<VirtualHost *:80>
ServerName myadmin.mysite.com
DocumentRoot /var/www/html/myadmin
DirectoryIndex index.php
<Directory /var/www/html/myadmin>
    AllowOverride All
    Allow from All
</Directory>
</VirtualHost>

But I want phpmyadmin to force a https connection. If I do that, in its configuration file config.inc.php via the following:

$cfg['ForceSSL'] = true;

I get redirected to a "Apache 2 Test Page" (on https). What do I need to change in order to keep the phpmyadmin connection solely on https

link|improve this question

60% accept rate
feedback

migrated from stackoverflow.com Mar 28 '11 at 16:52

This question came from our site for professional and enthusiast programmers.

3 Answers

You have to create a copy of your virtualhost, set it's port to 443 and add SSL configuration directives.

<VirtualHost *:443>
  ServerName myadmin.mysite.com

  SSLEngine on
  SSLProtocol all -SSLv2
  SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
  SSLCertificateFile conf/ssl-keys/server.crt
  SSLCertificateKeyFile conf/ssl-keys/server.key


  DocumentRoot /var/www/html/myadmin
  DirectoryIndex index.php
  <Directory /var/www/html/myadmin>
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>
link|improve this answer
feedback

define the ssl vhost as well

<ifmodule mod_ssl.c>

<virtualhost *:443>
servername myadmin.mysite.com
documentroot /var/www/html/myadmin
directoryindex index.php
#your rest of configs + ssl cert,key,etc
sslengine on
</virtualhost>
</ifmodule>
link|improve this answer
feedback

Some example with redirecting to https from http:

<VirtualHost *:443>
        ServerName myadmin.mysite.com

        SSLEngine On
        SSLCertificateFile {path-to-certificate}
        SSLCertificateKeyFile {path-to-key}
        DocumentRoot /var/www/html/myadmin
        DirectoryIndex index.php
        <Directory /var/www/html/myadmin>
            AllowOverride All
            Allow from All
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerName myadmin.mysite.com
        DocumentRoot /var/www/html/myadmin

        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.