Alexander Qvist-Hellum Alexander Qvist-Hellum - 1 month ago 11
Apache Configuration Question

HTTPS with exception

I am trying to figure out what is the best course of action for my website.

The issue is that I want HTTPS everywhere on my site except a specific folder.

I am not quite sure what changes need to be made or where they need to be made.

My current options-ssl-apache.conf is the following: http://pastebin.com/7AcK8SNh

My current 000-default-le-ssl.conf is the following: http://pastebin.com/HWaT2Z0Q

An option that I have considered is making my apache host two sites, one on port 80 which utilizes SSL and one on port 8080, containing only the folder that does not need HTTPS.
The folder in question is a folder with files that are downloaded when client connect to my game server and therefor it wouldn't be a problem if I simply host it on another port as I would just tell the game to download the files from 8080 instead.

Answer

Modifying this:

RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule !^garrysmod https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

to this:

RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteCond %{REQUEST_URI} !^/path/to/folder
RewriteRule !^garrysmod https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

should exclude http://www.example.com/path/to/folder/anything from being redirected to https://