0

I have an ISPConfig 3 site running on one domain. I have multiple vhost files for the different applications I run through Apache. I want to enable https://example.com/%QUERY_STRING% on every request that come through Apache with that domain. Right now, I have to paste

RewriteEngine on
RewriteCond %{HTTPS} ^off$
RewriteRule . https://example.com%{REQUEST_URI} [R,L] 

RewriteEngine on
RewriteCond %{HTTPS} ^on$
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule . https://example.com%{REQUEST_URI} [R,L] 

in every one of my vhosts. If I had to do this once, it wouldn't be a problem, but I constantly wipe my server and rebuild it from scratch (I have good reasons). I don't like going through all the vhosts and pasting this in every one, I know there must be a more technical way to do this. I tried putting this in my apache2.conf but this does not work. Also I can't turn on SSLEngine unless we are in a <Location> or <Directory> or something like that.

How do I do this?

ashraj98
  • 163
  • 2
  • 8

1 Answers1

0

Just put in your apache2.conf

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.com$1 [R,L] 

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.example\.com
RewriteRule (.*) https://example.com$1 [R,L] 
Froggiz
  • 3,043
  • 1
  • 19
  • 30