0

I want to set my server so it redirects http to https for phpmyadmin but only for phpmyadmin.

Basically what I want is when I type localhost in address bar to be http://localhost/ but when I type localhost/pma (which is my phpmyadmin folder) it goes to https://localhost/pma/

I am using Apache server on Windows 10 with self signed certificate just for learning and testing stuff out.

So is it possible to do redirect with VirtualHost or will I have to use mod_rewrite to achieve this?

Thanks

thor
  • 21,418
  • 31
  • 87
  • 173
PeroKC
  • 11
  • 1
  • 2
  • You can get a proper certificate from [lets encrypt](https://letsencrypt.org/) - stay protected! :) – JimL Mar 27 '16 at 20:50
  • 1. it makes absolutely no sense to use https in combination with `localhost` and 2. it is impossible to get a https certificate for that hostname. – arkascha Mar 27 '16 at 20:59
  • Thanks. It's all just for testing purposes. :) – PeroKC Mar 27 '16 at 21:04
  • also check http://stackoverflow.com/questions/16200501/http-to-https-apache-redirection – SteVoi Mar 28 '16 at 01:12

1 Answers1

-2

You could use mod_rewrite to achieve this goal. (.htaccess)

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} phpmyadmin
RewriteRule ^(.*)$ https://localhost/phpmyadmin/$1 [R,L]

Another way would be setting up a secure vHost.


I don't see a reason why you wouldn't just run the entire project in HTTPS, though.

The Thumb
  • 9
  • 3