0

I'm using this to force access to phpmyadmin onto HTTPS but it's staying on HTTP, other directives in the .htaccess file of the site work fine.

RewriteEngine On

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^/phpmyadmin/(.*)$ https://my.site.net/phpmyadmin/$1 [R,L]


<VirtualHost 89.24.24.24:80> 
DocumentRoot /home/site/public_html 
ServerName my.mysite.net 
ErrorLog /var/log/httpd/error_log 
ErrorLog /var/log/httpd/error_log 
CustomLog "|/usr/sbin/rotatelogs home/sitel/logs/access_log.%Y.%m.%d 86400" combined 
Options ExecCGI 
TraceEnable off 
RewriteEngine on 
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] 
</VirtualHost>


<VirtualHost 89.24.24.24:443>

DocumentRoot /home/site/public_html/phpmyadmin
ServerName my.mysite.net

SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/csvsvsv3.crt
SSLCertificateKeyFile /etc/pki/tls/private/site.key
SSLCertificateChainFile /etc/pki/tls/certs/bundle.crt

SSLProtocol -ALL +SSLv3 +TLSv1
SSLCipherSuite RC4:HIGH:!ADH:!DH:!AES:!EXPORT:!SSLv2:!3DES

Options ExecCGI

TraceEnable off

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</VirtualHost>



[rid#7f0269d20118/initial] (2) init rewrite engine with requested uri /phpmyadmin/
[rid#7f0269d20118/initial] (3) applying pattern '.*' to uri '/phpmyadmin/'
[rid#7f0269d20118/initial] (4) RewriteCond: input='GET' pattern='^(TRACE|TRACK)' => not-matched
[rid#7f0269d20118/initial] (1) pass through /phpmyadmin/
[rid#7f0269d26148/subreq] (2) init rewrite engine with requested uri /phpmyadmin/index.php
[rid#7f0269d26148/subreq] (3) applying pattern '.*' to uri '/phpmyadmin/index.php'
[rid#7f0269d26148/subreq] (4) RewriteCond: input='GET' pattern='^(TRACE|TRACK)' => not-matched
[rid#7f0269d26148/subreq] (1) pass through /phpmyadmin/index.php
[rid#7f0269d20118/initial] (2) init rewrite engine with requested uri /phpmyadmin/phpmyadmin.css.php
[rid#7f0269d20118/initial] (3) applying pattern '.*' to uri '/phpmyadmin/phpmyadmin.css.php'
[rid#7f0269d20118/initial] (4) RewriteCond: input='GET' pattern='^(TRACE|TRACK)' => not-matched
[rid#7f0269d20118/initial] (1) pass through /phpmyadmin/phpmyadmin.css.php
[rid#7f0269d20118/initial] (2) init rewrite engine with requested uri /phpmyadmin/themes/original/img/logo_right.png
[rid#7f0269d20118/initial] (3) applying pattern '.*' to uri '/phpmyadmin/themes/original/img/logo_right.png'
[rid#7f0269d20118/initial] (4) RewriteCond: input='GET' pattern='^(TRACE|TRACK)' => not-matched
[rid#7f0269d20118/initial] (1) pass through /phpmyadmin/themes/original/img/logo_right.png
[rid#7f0269d20118/initial] (2) init rewrite engine with requested uri /phpmyadmin/print.css
[rid#7f0269d20118/initial] (3) applying pattern '.*' to uri '/phpmyadmin/print.css'
[rid#7f0269d20118/initial] (4) RewriteCond: input='GET' pattern='^(TRACE|TRACK)' => not-matched
[rid#7f0269d20118/initial] (1) pass through /phpmyadmin/print.css
3
  • I've tested this : ServerA with Apache only and ServerB with Apache+phpmyadmin over SSL. Your actual Rewrite rules works fine. Are you using one or two servers (one as frontend and one as backend) ? Please provide your VHost config
    – krisFR
    Mar 24, 2014 at 21:48
  • Will try to reproduce on one server only. But please update your question with your VHost config using code tags : it is absolutely unreadable in comments
    – krisFR
    Mar 24, 2014 at 23:00
  • Ok I've done that, thanks for your help, I have to go offline for a bit though.
    – Lewis
    Mar 24, 2014 at 23:06

4 Answers 4

0

It might be that you're over-complicating this. I've never had to use mod-rewrite to do this; setting $cfg\['ForceSSL'\] = true; usually is all I need to do (provided of course that my Apache server is properly set up on the https side).

0
0

Try replacing your condition with

RewriteCond %{HTTPS} !=on
3
  • No luck, I wondering if it is to do with phpmyadmin being an alias and not in the webroot folder.
    – Lewis
    Mar 24, 2014 at 20:39
  • That shouldn't matter. Have a look at your /etc/httpd/conf.d directory and look for a phpmyadmin.conf & post its contents.
    – nageeb
    Mar 24, 2014 at 20:59
  • I've chnaged my IP but <Directory "/usr/share/phpmyadmin"> Order Deny,Allow Deny from all Allow from 800.90.222.22 </Directory> Alias /phpmyadmin /usr/share/phpmyadmin Alias /phpMyAdmin /usr/share/phpmyadmin Alias /mysqladmin /usr/share/phpmyadmin
    – Lewis
    Mar 24, 2014 at 21:03
0

this has worked for me before:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Since you seem to be on a shared host with no access to the main apache configuration files to enable RewriteLog, you can check this post for some ideas on how to debug the rewrite rules: https://stackoverflow.com/questions/9153262/tips-for-debugging-htaccess-rewrite-rules

8
  • I'm not on shared hosting, I don't think it being in htaccess is the issue?
    – Lewis
    Mar 24, 2014 at 21:27
  • No, the problem is that you cannot put a RewriteLog directive in htaccess files. If you can modify the server config, try with RewriteLogLevel 9 and RewriteLog "/var/log/apache2/rewrite.log" so you can see how the rewrite is being performed by the server. Change the path to the log file to one the server can write to, and post the contents to see if they can show us what's the problem.
    – rober710
    Mar 24, 2014 at 21:47
  • I don't have RewriteLog in the htaccces file
    – Lewis
    Mar 24, 2014 at 22:08
  • Yes, you can't put RewriteLog on htaccess, but you have to put it inside the virtualhost configuration. By the way, seeing your configuration, the ssl vhost is <VirtualHost 89.24.24.24:43> but the port seems wrong. SSL uses port 443, so it should be <VirtualHost 89.24.24.24:443>
    – rober710
    Mar 24, 2014 at 23:44
  • Sorry that was a typo when editing out the ip, it is on 443
    – Lewis
    Mar 26, 2014 at 11:02
-1

When i did it years ago as i remember i needed to configure ssl to use HTTPS. Ive been searching to find my notes, but no luck

try this guide instead. Its for Linux, so if your on another system, at least it will point you to the right direction

http://www.howtoforge.com/how-to-set-up-an-ssl-vhost-under-apache2-on-ubuntu-9.10-debian-lenny

1
  • The https is working fine when I navigate directly to it, it's just the re-write isn't doing anything.
    – Lewis
    Mar 24, 2014 at 21:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .