Howto phpmyadmin and https

Hi Folks,

in this small tutorial I’m trying to explain how to make phpmyadmin working only with https. It’s really very easy so far. I did this on a Debian 5.03 Server but in most of cases it’s similar to any linux distribution. So let’s go:

  1. create a .htaccess file on /usr/share/phpmyadmin
    cd /usr/share/phpmyadmin
    vim .htaccess
  2. enter the following lines:
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !=443
    RewriteRule ^ https://yourdomain.or.IP%{REQUEST_URI} [NS,R,L]
  3. save the file
    wq!
  4. after that open your phpmyadmin apache conf file
    vim /etc/phpmyadmin/apache.conf
  5. edit the following line to your script
    # phpMyAdmin default Apache configuration

    Alias /phpmyadmin /usr/share/phpmyadmin

    <Directory /usr/share/phpmyadmin>
    Options Indexes FollowSymLinks
    DirectoryIndex index.php
    AllowOverride All
    .
    .

  6. Now you can save the file => wq!
  7. restart your server
    /etc/init.d/apache2 restart
  8. Congratulations that’s all now you’ll be always redirected to https

This process can be done with all folders you want to be redirected to https. Just create a .htaccess file with the necessary lines and don’t forget to set up a <directory > tag into your available site.

For example I want to redirect a folder located in “/var/www/testfolder” . First you have to create and copy a .htaccess into the “testfolder” and then you should edit your current activ “sites-available” document like in the example below.

<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory /var/www>
Options Indexes FollowSymLinks
DirectoryIndex index.php
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory /var/www/testfolder>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Tags: , , , , , ,

Leave a Reply