1

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

1

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>
0

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>
0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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