Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

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

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

3 Answers 3

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>
share|improve this answer

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>
share|improve this answer

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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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