Web-server – Disable https for a single file in apache

.htaccessapache-2.4httpsweb-hostingweb-server

For a long time, I didn't use https on my linux server because I didn't find a decent CA that suits my needs. Now, Let's Encrypt (a new CA that provides free certificates) has launched their open beta so I got a certificate from them right away.

I am now redirecting all requests to https and everything works fine so far but since I have used http for ages, I will need some time to rewrite some client software that depends on the wbesite being http. Unfortunately I cannot deploy the update right away since the update mechanism is now broken too :/

So my question is: Is there a way to disable https for one single file in apache2? I'd prefer a solution using a simple .htaccess file but anything else is appreciated as well.

This was added to the VirtualHost *:80 by letsencrypt:

RewriteEngine on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,QSA,R=permanent]

Best Answer

On your default vhost, try the following:

 RewriteEngine on
 RewriteCond %{HTTPS} !=on
 RewriteCond %{REQUEST_URI} !^/path/to/your_single_file.html$
 RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,QSA,R=permanent]